You can do this by using a recordset, like this:
Sub GetStrings()
Dim DB As DAO.Database, RS As DAO.Recordset
Set DB = CurrentDb
Set RS = DB.OpenRecordset("Query Name")
Do Until RS.EOF
'FieldName stands for the field name in the query that you want
'to retrieve; in this case it is simply shown in the output window
Debug.Print RS.Fields("FieldName")
RS.MoveNext
Loop
Set RS = Nothing
Set DB = Nothing
End Sub
Quote:
Originally posted by bobbyg9
I have managed to open a Query through a Macro in Access, and i can traverse the records too, via the
DoCmd.GoToRecord acDataQuery, "Query Name"
command.
However, I was wondering if there is a way I could actually get the current record information in a String, so that I can write this string to a file.
i.e. My high level pseudo code is:
while(No more records)
curRecord = getCurrentRecord; // HOW DO I DO THIS ?
write CurRecord to a textfile;
goto nextRecors.
end
Any insight will be highly appreciated !
Thanks,
bobby
|