Access records from table

A

Ac

Hi,

I would like to retrieve data records from either table or query, and then
do the calculation from them. Below is part of code to get the records, and I
got the error message on the “Set rst1 = tdf1.OpenRecordsetâ€, that is “the
method or data member not foundâ€. How can I get a record from the table? (The
table name is “InputDataâ€)

Public Sub DataCalculation(ID As Long)

Dim db As DAO.Database
Dim tdf1 As DAO.TableDefs
Dim qdf2 As DAO.QueryDefs

Dim rst1 As DAO.Recordset
Dim rst2 As DAO.Recordset

Set db = CurrentDb
Set tdf1 = db.TableDefs("InputData")
Set qdf2 = db.QueryDefs("qCasing")

Set rst1 = tdf1.OpenRecordset
Set rst2 = qdf2.OpenRecordset
…
 
R

raskew via AccessMonster.com

Hi -

Try this:

Set db = CurrentDb

Set rst1 = db.OpenRecordset("InputDate")
Set rst2 = db.OpenRecordset("qCasing")

HTH - Bob
 
F

FindSolution

Thank you for your help. The last problem is solved. Now the error from the
next line of code: VolumePumped = rs1![Pump in Increment] , the error message
is: “Object requiredâ€. The [Pump in Increment] is the field in InputData
table. Could you help me again? Thanks.


Public Sub DataCalculation(ID As Long)

Dim db As DAO.Database
Dim tdf1 As DAO.TableDefs
Dim qdf2 As DAO.QueryDefs

Dim rst1 As DAO.Recordset
Dim rst2 As DAO.Recordset

Set db = CurrentDb

Set rst1 = db.OpenRecordset("InputData")
Set rst2 = db.OpenRecordset("qCasing")

VolumePumped = rs1![Pump in Increment]
…
 
J

John W. Vinson

Thank you for your help. The last problem is solved. Now the error from the
next line of code: VolumePumped = rs1![Pump in Increment] , the error message
is: “Object required”. The [Pump in Increment] is the field in InputData
table. Could you help me again? Thanks.


Public Sub DataCalculation(ID As Long)

Dim db As DAO.Database
Dim tdf1 As DAO.TableDefs
Dim qdf2 As DAO.QueryDefs

Dim rst1 As DAO.Recordset
Dim rst2 As DAO.Recordset

Set db = CurrentDb

Set rst1 = db.OpenRecordset("InputData")
Set rst2 = db.OpenRecordset("qCasing")

VolumePumped = rs1![Pump in Increment]

You're defining a recordset named

rst1

and trying to read from a recordset named

rs1

Note the spelling difference.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top