retrieving field values in Access

retrieving field values in Access

Post by Alex Dunke » Sun, 28 Jun 1998 04:00:00



Is ther an easier way to obtain and store record values from a table (in
Access '97) than the way shown below:

    Dim DB As Database
    Dim worksp As Workspace
    Dim RS As Recordset
    Dim appPath As String, dbName As String

    appPath = "C:\"
    dbName = appPath & "\db1.mdb"
    Set worksp = DBEngine.Workspaces(0)
    Set DB = worksp.OpenDatabase(dbName)

    Set RS = DB.OpenRecordset("Table1", dbOpenTable)
    RS.MoveFirst
    temp_var = RS(1).Value

I'm hoping there's a way to not specify the database name and location,
since the database is only working with it's own tables.  I just can't
seem to find it in the help files.

Please e-mail me directly if you can help.

Thanks in advance.

- Alex

 
 
 

retrieving field values in Access

Post by Jim Fergus » Mon, 29 Jun 1998 04:00:00


Quote:>I'm hoping there's a way to not specify the database name and location,
>since the database is only working with it's own tables.  

You lost me. Some how, some way, you have to tell your program where
the database is.

-- Jim Ferguson, FMS
   http://www.fmsinc.com

 
 
 

retrieving field values in Access

Post by Lorrin L. William » Mon, 29 Jun 1998 04:00:00


If you are working in Access then the answer is YES.  Make a form that is
connected to the data you want.  If you are in Access than the only database
you are connected to is the one you have open or imported tables.  The code
I see you using is DAO, which is what access does in the background for you.
If you want to see one record at a time from a table you can let the form
wizard in access build it for you.
    If you are working on a VB front end and an Access DB then yes you do
have to tell the front end where to find the info.

HTH,
Lorrin L. Williams
Karma Komputing
"The Unexamined Life is not worth Living" - Socrates


>Is ther an easier way to obtain and store record values from a table (in
>Access '97) than the way shown below:

>    Dim DB As Database
>    Dim worksp As Workspace
>    Dim RS As Recordset
>    Dim appPath As String, dbName As String

>    appPath = "C:\"
>    dbName = appPath & "\db1.mdb"
>    Set worksp = DBEngine.Workspaces(0)
>    Set DB = worksp.OpenDatabase(dbName)

>    Set RS = DB.OpenRecordset("Table1", dbOpenTable)
>    RS.MoveFirst
>    temp_var = RS(1).Value

>I'm hoping there's a way to not specify the database name and location,
>since the database is only working with it's own tables.  I just can't
>seem to find it in the help files.

>Please e-mail me directly if you can help.

>Thanks in advance.

>- Alex


 
 
 

retrieving field values in Access

Post by Alex Dunke » Mon, 29 Jun 1998 04:00:00


Is ther an easier way to obtain and store record values from a table (in
Access '97) than the way shown below:

    Dim DB As Database
    Dim worksp As Workspace
    Dim RS As Recordset
    Dim appPath As String, dbName As String

    appPath = "C:\"
    dbName = appPath & "\db1.mdb"
    Set worksp = DBEngine.Workspaces(0)
    Set DB = worksp.OpenDatabase(dbName)

    Set RS = DB.OpenRecordset("Table1", dbOpenTable)
    RS.MoveFirst
    temp_var = RS(1).Value

I'm hoping there's a way to not specify the database name and location,
since the database is only working with it's own tables.  I just can't
seem to find it in the help files.


Thanks in advance.

- Alex

 
 
 

retrieving field values in Access

Post by Gary Labowit » Tue, 30 Jun 1998 04:00:00


Dim DB as Database
Dim RS as Recordset

Set DB = CurrentDB
Set RS = DB.OpenRecordset ("Table1", dbOpenTable)

temp_var = RS("fieldName")   ' [or RS(1) if you insist]

HTH -- you shouldn't sleep in class!
--
Gary (MCT, MCPS, MCSD)
http://www.enter.net/~garyl/  for essary on recovery and good books

ICQ 6375624



> Is ther an easier way to obtain and store record values from a table (in
> Access '97) than the way shown below:

>     Dim DB As Database
>     Dim worksp As Workspace
>     Dim RS As Recordset
>     Dim appPath As String, dbName As String

>     appPath = "C:\"
>     dbName = appPath & "\db1.mdb"
>     Set worksp = DBEngine.Workspaces(0)
>     Set DB = worksp.OpenDatabase(dbName)

>     Set RS = DB.OpenRecordset("Table1", dbOpenTable)
>     RS.MoveFirst
>     temp_var = RS(1).Value

> I'm hoping there's a way to not specify the database name and location,
> since the database is only working with it's own tables.  I just can't
> seem to find it in the help files.


> Thanks in advance.

> - Alex


 
 
 

retrieving field values in Access

Post by Allen Brown » Tue, 30 Jun 1998 04:00:00


If the database is the current one, just use:
    Set db = CurrentDb()
instead of specifying path and name.

If you just want to read the value, you can avoid this
altogether. See article "Getting a value from a table: DLookup()" at:
        http://odyssey.apana.org.au/~abrowne/casu-07.html


> Is ther an easier way to obtain and store record values from a table (in
> Access '97) than the way shown below:

>     Dim DB As Database
>     Dim worksp As Workspace
>     Dim RS As Recordset
>     Dim appPath As String, dbName As String

>     appPath = "C:\"
>     dbName = appPath & "\db1.mdb"
>     Set worksp = DBEngine.Workspaces(0)
>     Set DB = worksp.OpenDatabase(dbName)

>     Set RS = DB.OpenRecordset("Table1", dbOpenTable)
>     RS.MoveFirst
>     temp_var = RS(1).Value

> I'm hoping there's a way to not specify the database name and location,
> since the database is only working with it's own tables.  I just can't
> seem to find it in the help files.



 
 
 

retrieving field values in Access

Post by Jim Fergus » Tue, 30 Jun 1998 04:00:00


Quote:>If the database is the current one, just use:
>    Set db = CurrentDb()
>instead of specifying path and name.

Currentdb() is not available from VB...

-- Jim Ferguson, FMS
   http://www.fmsinc.com

 
 
 

1. retrieving field values in Access

Is ther an easier way to obtain and store record values from a table (in
Access '97) than the way shown below:

    Dim DB As Database
    Dim worksp As Workspace
    Dim RS As Recordset
    Dim appPath As String, dbName As String

    appPath = "C:\"
    dbName = appPath & "\db1.mdb"
    Set worksp = DBEngine.Workspaces(0)
    Set DB = worksp.OpenDatabase(dbName)

    Set RS = DB.OpenRecordset("Table1", dbOpenTable)
    RS.MoveFirst
    temp_var = RS(1).Value

I'm hoping there's a way to not specify the database name and location,
since the database is only working with it's own tables.  I just can't
seem to find it in the help files.


Thanks in advance.

- Alex

2. Oracle and Tuxedo

3. DALLAS -- Sr. Programmer Analyst

4. Retrieve MS Access field property values?

5. Adding a 2nd Private Network Connection to Existing Setup

6. retrieve only time value from datetime field?

7. Oracle Resources (JOBS, RESUMES, LINKS, TUNING SCRIPT)!

8. Retrieve Fields' Default Values info

9. Retrieve Autoincrement Field Value Using ODBC?

10. retrieving value from UniqueIdentifier field

11. Retrieving the value of an identity field of a new record

12. SQL Server: How to retrieve the value of an AutoNumber field after the INSERT