I have a generic report that I want to change the underlying recordsource on each time I open it. Is there a way to dynamically change the recordsource property without having to code a recordset?
Hi,
Yes, you can do this inside the Open event for the report. Let's say that you are trapping the user name via code (see my FAQ at faq705-2814), and you wish to change the recordsource depending on the user. Here is how to do it:
'open event of report
Dim strUser as String
strUser = fWin2KUserName ' function from my FAQ
Select case strUser
Case "John Doe" 'manager access
Me.Recordsource = "qryEmployeeReportWithPersonal"
Case "Bob Uptonogood" 'other employee
Me.Recordsource = "qryEmployeeReportWithJustName"
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.