[ms-access] How to execute a query in ms-access in VBA code?

How can I execute a query to return records in an ms-access database using VBA code?

This question is related to ms-access vba

The answer is


How about something like this...

Dim rs As RecordSet
Set rs = Currentdb.OpenRecordSet("SELECT PictureLocation, ID FROM MyAccessTable;")

Do While Not rs.EOF
   Debug.Print rs("PictureLocation") & " - " & rs("ID")
   rs.MoveNext
Loop