user defined type not defined

carlton123

Registered User.
Local time
Today, 10:42
Joined
Mar 18, 2011
Messages
48
im using following code I got from the web im using access 2000 im just running this from a command button on a blank form with a table called "DOG" im just trying to loop through the table so I can try to get round another problem I have its coming up with error on the DAO bits??

Private Sub Command0_Click()


Dim dbs As DAO.Database
Dim tdf As DAO.TableDef ' use this for a table
Dim qdf As DAO.QueryDef 'use this for a query
Dim rst As DAO.Recordset
Dim fld As DAO.Field

'Set dbs = CurrentDb
'Set tdf = dbs.TableDefs("DOG")

' List fields
For Each fld In tdf.Fields
Debug.Print fld.Name
Next fld

Set rst = tdf.OpenRecordset

' Loop through records
Do Until rst.EOF
For Each fld In rst.Fields
Debug.Print fld.Name & "=" & fld.Value
Next fld
rst.MoveNext
Loop

rst.Close
Set rst = Nothing
Set fld = Nothing
Set qdf = Nothing
Set tdf = Nothing
Set dbs = Nothing

End Sub
 
the
'Set dbs = CurrentDb
'Set tdf = dbs.TableDefs("DOG")
should not be commented out but it doesnt work either way!
 
In 2000 you'd have to check the MS DAO 3.6 object library in Tools References.
 
why does this not work?

Set dbs = CurrentDb
Set tdf = dbs.TableDefs("DOG")

if there is a table called DOG, this should work. What error do you get?


-------------------------------
this is not right, though

Set rst = tdf.OpenRecordset

what are you trying to do exactly?
 
Last edited:
In the VBA editor, not Access
 
aah. I see what Paul means. DAO is not referenced by default.
 

Users who are viewing this thread

Back
Top Bottom