carlton123
Registered User.
- Local time
- Today, 07:53
- 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
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