Link to home
Start Free TrialLog in
Avatar of raterus
raterusFlag for United States of America

asked on

Change a report's recordsource at runtime

Hello Experts!

I have "Report1", and sometimes I want the recordsource of Report1 to be Query "ABC", and sometimes I want the recordsource to be Query "XYZ".

I'm at the code right before I DoCmd.OpenReport, and I need to make this change.  Can someone help me.  I was trying to do this, but it didn't work.

    stDocName = "Report1"
    Application.Reports(stDocName).RecordSource = "ABC"
    DoCmd.OpenReport stDocName, acPreview

Oh yes, I'm using Access 97!
SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of raterus

ASKER

I saw the OpenArgs solution while searching, but I'm using Access 97 and it isn't available.  Can I just keep track of the "Args" using a global variable, that's what I'm trying now.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of raterus

ASKER

Great help guys, I got it working exactly the way I needed it.
Avatar of RgGray3
RgGray3

Glad to assist