NMiller007
Programmer
I am trying to use a recordsource to cycle through different report criteria. I need the report to display for every user and then this report will be e-mailed.
Here is my code:
SaySomething stores each record, but when I try and combine them, WhereCriteria is Null (the MsgBox is blank). When this is run, I get a MsgBox that displays the first record, then a MsgBox that is blank. Then the next record and blank and so on. The report comes up, but displays every record and doesn't reload each time.
What am I doing wrong? Is there another way I'm supposed to reference each member of the recordset? Is there another way to do this altogether?
Thank you.
Here is my code:
Code:
Dim db As DAO.Database
Dim rsUsers As DAO.Recordset
Dim UsersSQL As String
Dim WhereCriteria As String
Dim SaySomething As String
UsersSQL = "SELECT * FROM Users;"
Set db = CurrentDb
Set rsUsers = db.OpenRecordSet(UsersSQL)
Do Until rsUsers.EOF
SaySomething = rsUsers!user_name
MsgBox (SaySomething)
WhereCritera = "[user_name] = " & SaySomething
MsgBox (WhereCriteria)
DoCmd.OpenReport "InspectionSpreadsheet", acViewPreview, "", WhereCriteria
rsUsers.MoveNext
Loop
rsUsers.Close
SaySomething stores each record, but when I try and combine them, WhereCriteria is Null (the MsgBox is blank). When this is run, I get a MsgBox that displays the first record, then a MsgBox that is blank. Then the next record and blank and so on. The report comes up, but displays every record and doesn't reload each time.
What am I doing wrong? Is there another way I'm supposed to reference each member of the recordset? Is there another way to do this altogether?
Thank you.