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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

One report with different query sources

Status
Not open for further replies.

irethedo

Technical User
Feb 8, 2005
429
US
I have one report where I want to be able to choose different query sources based upon a drop down list on a form.

I have 4 seperate queries and they work when I run them seperately but when I run the report, the data displayed doesn't totally match the data of my query.

This is probably something simple i am overlooking...

Here is my code:

=====

Select Case Me!psteam

Case 1 ' ALL
Reports("Report1").RecordSource = "ALL qry"

Case 2 ' CELLA
Reports("Report1").RecordSource = "CELLA qry"

Case 3 ' CELLB
Reports("Report1").RecordSource = "CELLB qry"

Case 4 ' CELLC
Reports("Report1").RecordSource = "CELLC qry"

End Select

DoCmd.OpenReport "Report1", PrintMode

=======
Is my syntax correct?

Thanks in advance
 
You can't change the recordsource of a report that isn't open. Try add code to the On Open event of the report:
Code:
Select Case Forms!frmYourForm!psteam

    Case 1 ' ALL
       Me.RecordSource = "ALL qry"
  
    Case 2 ' CELLA
       Me.RecordSource = "CELLA qry"
  
     Case 3 ' CELLB
       Me.RecordSource = "CELLB qry" 

     Case 4 ' CELLC
       Me.RecordSource = "CELLC qry"

   End Select

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Thank you dhookom-

- that solution worked great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top