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

Setting Report Datasource problem

Status
Not open for further replies.

wokkie

Programmer
May 9, 2003
52
GB
Hi,

I am using Access 2003 with a SQL Server 2000 backend.

I want to use a single Report with several different queries, one at a time.

I have the code:

DoCmd.OpenReport "rptJournalMailingLabels", acViewPreview, "qryJournalMailingCurrentIssueSingle"

But this doesn't work. How do I dynamically set the Report datasource?

Thanks

Ian
 
Ian,

When you say it "doesn't work", what happens, do you get an error message, are incorrect records returned, etc.??

Where is your DoCmd statement located??

Hoc nomen meum verum non est.
 
There are no records in the report, it seems that the data source hasn't been set.

The DoCmd is behind a command button on a form.

Cheers

Ian
 
I have managed to set the datasource using the Report's "On Open" method, but this meant than I had to use a combo to select the query I wanted and use a case select statment to set the correct one.

I would prefer to be able to use the DoCmd to set the query.

Thanks

 
Just don't want to overlook the obvious:

When you run the query independently of the report, do you get the correct records returned??

Also, what is the default record source set to for the report??

Hoc nomen meum verum non est.
 
The report works fine when run on its own.

The default rs is "qryJournalMailingBase" another query.

Thanks again for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top