Macro to open up all 5 reports

  • Thread starter Johnny-Walker via AccessMonster.com
  • Start date
J

Johnny-Walker via AccessMonster.com

I am using a macro to open 5 seperate reports but when I open a report you
have to use an assigned ID number to retrieve the right employee information
you are looking for. At present you have to enter the employee ID # all 5
times for each report, how can I set this up to open up all 5 reports without
having to enter employee ID number all 5 times?
 
M

Marshall Barton

Johnny-Walker via AccessMonster.com said:
I am using a macro to open 5 seperate reports but when I open a report you
have to use an assigned ID number to retrieve the right employee information
you are looking for. At present you have to enter the employee ID # all 5
times for each report, how can I set this up to open up all 5 reports without
having to enter employee ID number all 5 times?


Create a form with a text or combo box for the ID and a
button to open the report. Remove the ID criteria from the
reports' record source queries.

The code for the button's Click event procedure could look
something like:

Dim stWhere As String
stWhere = "ID=" & Me.ID 'not sure about your field names
DoCmd.OpenReport "first report", acViewPreview, , stWhere
DoCmd.OpenReport "2nd report", acViewPreview, , stWhere
DoCmd.OpenReport "3rd report", acViewPreview, , stWhere
DoCmd.OpenReport "4th report", acViewPreview, , stWhere
DoCmd.OpenReport "5th report", acViewPreview, , stWhere
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top