Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing record source everytime I open a report

Status
Not open for further replies.

tdfreeman

MIS
Mar 28, 2002
85
US
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?

Thanks,

Tammy Thank you for your help.

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

End Select

HTH, [pc2]
Randy Smith
California Teachers Association
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top