query to select one record using report name

G

Guest

I have a report which is based on a table which contains one record for each of my reports (title, code no etc), I want to create one query as the record source for all of the reports which will select the reord it needs based which report is calling it. I tried lots of variations Me.Name, Reports!me.Name etc etc but the query does not run. How can I use the name of the report in the query???
Thanks to anyone who can help
 
J

Jeff Boyce

I'm not sure I understand.

You have multiple reports, but you want one query to serve as a source for
them all? Are all the reports identical in layout?

Or are you trying to provide a way, on a form, to pick a report, then run
it?
 
G

Guest

All my reports have the same layout, the different data is in a subreport with its own record source. I just want a query to select a record from a table where the primary key is the name of the report. i.e WHERE reportname = Me.Name, but this does not work. Thanks for your hel

----- Jeff Boyce wrote: ----

I'm not sure I understand

You have multiple reports, but you want one query to serve as a source fo
them all? Are all the reports identical in layout

Or are you trying to provide a way, on a form, to pick a report, then ru
it
 
J

Jeff Boyce

Nasos

Have you looked into the

DoCmd.OpenReport ...

command? You might be able to add code behind your form that opens the
report selected in your form. By the way, if your example was an accurate
representation, you'll want to change how you've named your form's
control(s).

"Name" is a reserved word in Access.

Me.Name tells Access to return the 'Name' property of the form ('Me')

If you want to refer to the value contained in a control on a form, you
would use

Me!YourControl (and don't name YourControl as "Name"!)
 
G

Guest

Thanks for your answer but I don't have the problem with opening the report, the problem arises once I have opened the report. The problem is the query that I use as the record source. I want to use the name of the report in the query (the record source of the report). The trouble is I don't know how to refer to the report name in the query. Me.Name refers to the name of the query not the report. I have also tried Reports!report.name and other variations but of course they are not right. I need the actual name of the report each time to look up the appropriate record in the table which contains information to be printed on the report. Now I have a query for each report with its name. I would prefer to have one query which has a parameter which equates to the report name at run time

----- Jeff Boyce wrote: ----

Naso

Have you looked into th

DoCmd.OpenReport ..

command? You might be able to add code behind your form that opens th
report selected in your form. By the way, if your example was an accurat
representation, you'll want to change how you've named your form'
control(s)

"Name" is a reserved word in Access

Me.Name tells Access to return the 'Name' property of the form ('Me'

If you want to refer to the value contained in a control on a form, yo
would us

Me!YourControl (and don't name YourControl as "Name"!
 

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