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
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