object required

fanfan2

Registered User.
Local time
Today, 10:54
Joined
Feb 26, 2007
Messages
61
I have the following code:

Private Sub Command6_Click()

Dim curDatabase As Object
Dim rstSheet As Object
Dim hIDN As String

Set curDatabase = CurrentDb
Set rstSheet = curDatabase.OpenRecordset("tblSheet")
rstSheet.Movefirst
Set hIDN = rstSheet("FID").Value

msgbox(hIDN)

End Sub

then I got the error message: object required (hIDN). Did I miss anything?

Thanks in advance.
 
Drop the word "Set":

hIDN = rstSheet("FID").Value
 
You couldd try:

Private Sub Command6_Click()

Dim curDatabase As Object
Dim rstSheet As Recordset
Dim hIDN As String

Set curDatabase = CurrentDb
Set rstSheet = curDatabase.OpenRecordset("tblSheet")
rstSheet.Movefirst
hIDN = rstSheet("FID").Value

msgbox(hIDN)

End Sub
 
If you used Bob's changes, you should also disambiguate:

Dim curDatabase As DAO.Database
Dim rstSheet As DAO.Recordset
 

Users who are viewing this thread

Back
Top Bottom