passing parameter from a command button to a report

  • Thread starter Thread starter JWCrosby
  • Start date Start date
J

JWCrosby

I have a report based on a simple query. One of the fields in the query is
BuildingName.

I also have a form with three command buttons on it, each labeled with the
name of a different building. I want to be able to select which building name
to use as a parameter for the report by clicking the corresponding command
button, thus sending the BuildingName parameter to the report query.

I am having trouble coding the DoCmd.OpenReport line to pass the
BuildingName to the report query.

I know I could make three separate, but identical, reports each with a
slightly different query and have each button activate a different report,
but I'd like to have just one report design to contend with.

Thanks in advance for any help.

Jerry
 
Use the Where argument when you call the report. Something like

For the first button:
DoCmd.OpenReport "NAME Of Report",,,"BuildingNameField= ""Chrysler Building""")

For the second button:
DoCmd.OpenReport "NAME Of Report",,,"BuildingNameField= ""Chicago Tower""")


John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
 
Thanks, John. That did the trick. It was all those quotation marks that had
messed me up! (You had a closing paranthesis without an opener, but I did
without and it worked.)

Jerry
 
Back
Top