scubadiver007
Registered User.
- Local time
- Today, 09:05
- Joined
- Nov 30, 2010
- Messages
- 317
I have this code which loops through 55 records. How can I use the "code" field as the source for a query which I then export to a spreadsheet using a module?
Dim rst As DAO.Recordset
Dim db As DAO.Database
dim strsql as string
Set db = CurrentDb()
'Change this to your SQL or to the name of a saved query
Set rst = db.OpenRecordset("Select code from tble_practice;")
With rst
' Very important to avoid errors if no records are returned
If Not (.EOF And .BOF) Then
'movefirst isn't strictly necessary - but just in case
.MoveFirst
Do Until .EOF
'do something with record
MsgBox !code
.MoveNext
Loop
End If
.Close
End With
Set rst = Nothing
Set db = Nothing