VB Filter Access Report Based On Variable

I have an Access report that I would like to loop through and print filtering by the Supervisor Name.
I tried the following code, but the report is blank.

the strSupv does match the Supervisor field on the report.

Any advice would be appreciated.

Public Function PrintReports()
Dim strSupv As String
Dim rsSUPV As New ADODB.Recordset

rsSUPV.ActiveConnection = CurrentProject.Connection
rsSUPV.Open "tblSupervisorName"

Do While Not rsSUPV.EOF
strSupv = rsSUPV("SupName")
DoCmd.OpenReport "rptEmployeeWorkList", acViewPreview, , "[Supervisor] = 'strSupv'"
End Function
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

It should be:
DoCmd.OpenReport "rptEmployeeWorkList", acViewPreview, , "[Supervisor] = '" & strSupv & '"

Open in new window

But why not just include tblSupervisorName in the RecordSource of your report so that it will show all the reports with separate pages for each supervisor?


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ScamquistAuthor Commented:
Thank you for the assist.

I had to add a " after the last &
DoCmd.OpenReport "rptEmployeeWorkList", acViewPreview, , "[Supervisor] = '" & strSupv & "'"

I need to print the pages for the supervisor and loop because I have a couple of reports based on the supervisor, so this way I can collate them.

I appreciate the assist
ScamquistAuthor Commented:
Thank you for you help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.