Link to home
Start Free TrialLog in
Avatar of Fritz Paul
Fritz PaulFlag for South Africa

asked on

Help me see my error with VBA recordset

What am I doing wrong.
I am simply trying to run through a Table1 and list all the FirstNames.
Please look at the attached picture to see what everything looks like.
Also here is the code:
Option Compare Database

Private Sub Command0_Click()
Dim db As Database
Dim FName As String
    
Set db = CurrentDb

Dim rst0 As DAO.Recordset
   
    Set rst0 = db.OpenRecordset("Table1")
    rst0.MoveFirst
    Do Until rst0.EOF
        FName = rst0.[FirstName]
        Debug.Print FName
    rst0.MoveNext
    Loop
    Debug.Print "Completed"

End Sub

Open in new window


The error is "method or data member not found."User generated imageI will also attach the database.
DatabaseTest.accdb
Avatar of Norie
Norie

Is FirstName definitely the field name?

Could it be that it's the caption rather than the field name?
SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Fritz Paul

ASKER

Thanks Rey.
Gustav your suggestion also works.
Of course. Don't know it was duplicated two hours later.

/gustav