Access 2000 VBA Handbook

Category: Programming
Author: Susann Novalis
This Month Stack Overflow 1


by anonymous   2019-01-13

It's a bit dated, so you might want to grab a book on the subject. But, here's a ton of access resources and some tutorials and examples as well. But, basically ...

Dim dbs As Database
Dim rs As Recordset
Dim strSQL As String
Set dbs = CurrentDb

strSQL = 'your query here

Set rs = dbs.OpenRecordset(strSQL)

If Not (rs.EOF And rs.BOF) Then
  'get results using rs.Fields()

'Use results

Per comment: Take a look at the recordset class. It contains a collection called Fields that are the columns that are returned from your query. Without knowing your schema, it's hard to say, but something like ...

Do While Not rs.EOF
   'do something like rs("SomeFieldName") 

Like I said, your best bet is to grab a book on this subject, they have tons of examples.