Recordsets

ski_diva

New member
Local time
Today, 00:39
Joined
Oct 4, 2001
Messages
5
Hi there!

I'm used to writing SQL stored procedures for SQL Server, so I'm not sure how to approach Access.

I'd like to use a SQL statement, let's say SELECT * FROM ThisTable and then loop through the results of one field. I know how to do it with a stored procedure and Visual Basic, but not in Access.

Below is what I have so far - but it complains when it gets to the "Set db = CurrentDb()", it says that it's user-defined. So I'm not sure what I'm doing wrong.

Here's my procedure:

Private Sub pGetTrainer()

Dim db As database
Dim rs As Recordset
Dim sSQL As String
Dim sMsg As String

Set db = CurrentDb()

sSQL = "SELECT Trainers.FirstName FROM Trainers"

Set rs = db.openRecordset(sSQL)

Do
MsgBox "rs(0)= " & rs(0)

Loop Until rs.EOF

End Sub

Thank you, I appreciate your help!!
Andrea
 

Users who are viewing this thread

Back
Top Bottom