how can I find the name of my current report

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to find the name of the current report and use it to select a record from a table which contains one record for each available report, so I can customise the header of the current report with its specificic title and a few other details from the same table.The report name is in the table is called rptid is 8 chars and is the primary key of the table.How can I reference it I have a query which SELECTs all the fields in the table WHERE rptid = "reportname", but dispite trying many thing eg Me.name etc I can't find the name. Thanks for help.
 
Try a text box with Control Source of:
=DLookup("MyTitleField", "MyTable", "rptid = """ & [Report].[Name] & """")

Replace MyTitleField with the name of the field that contains the title to
show on the report. Replace MyTable with the name of the table. Leave the
3rd argument as is.

More help on DLookup():
http://allenbrowne.com/casu-07.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Nasos said:
I want to find the name of the current report and use it to select a
record from a table which contains one record for each available report, so
I can customise the header of the current report with its specificic title
and a few other details from the same table.The report name is in the table
is called rptid is 8 chars and is the primary key of the table.How can I
reference it I have a query which SELECTs all the fields in the table WHERE
rptid = "reportname", but dispite trying many thing eg Me.name etc I can't
find the name. Thanks for help.
 
Thanks for your answer but I,m afraid that it does not work in my report. The report runs but without finding the record in the table which contains the necessary information, it does not find any record, so the fields are blank. If I put a record source for the report as a query where I have the name explicitly, then the report works Ok.(its title, code number etc-which print in the header

----- Allen Browne wrote: ----

Try a text box with Control Source of
=DLookup("MyTitleField", "MyTable", "rptid = """ & [Report].[Name] & """"

Replace MyTitleField with the name of the field that contains the title t
show on the report. Replace MyTable with the name of the table. Leave th
3rd argument as is

More help on DLookup()
http://allenbrowne.com/casu-07.htm

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.htm
Reply to group, rather than allenbrowne at mvps dot org

Nasos said:
I want to find the name of the current report and use it to select
record from a table which contains one record for each available report, s
I can customise the header of the current report with its specificic titl
and a few other details from the same table.The report name is in the tabl
is called rptid is 8 chars and is the primary key of the table.How can
reference it I have a query which SELECTs all the fields in the table WHER
rptid = "reportname", but dispite trying many thing eg Me.name etc I can'
find the name. Thanks for help
 
To debug your issue, open the Immediate Window (Ctrl+G), and enter:
? =DLookup("MyTitleField", "MyTable", "rptid = ""SomeReportName""")

Work with that until you can figure out what's going on.

If you are not sure how to form the 3rd argument for DLookup() follow the
link in the previous reply.

BTW, make sure this text box does not have the same Name as one of your
fields. You confuse Access if it has the same name as a field but is bound
to an expression.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Nasos said:
Thanks for your answer but I,m afraid that it does not work in my report.
The report runs but without finding the record in the table which contains
the necessary information, it does not find any record, so the fields are
blank. If I put a record source for the report as a query where I have the
name explicitly, then the report works Ok.(its title, code number etc-which
print in the header)
----- Allen Browne wrote: -----

Try a text box with Control Source of:
=DLookup("MyTitleField", "MyTable", "rptid = """ & [Report].[Name] & """")

Replace MyTitleField with the name of the field that contains the title to
show on the report. Replace MyTable with the name of the table. Leave the
3rd argument as is.

More help on DLookup():
http://allenbrowne.com/casu-07.html

Nasos said:
I want to find the name of the current report and use it to select
a
record from a table which contains one record for each available report, so
I can customise the header of the current report with its specificic title
and a few other details from the same table.The report name is in the table
is called rptid is 8 chars and is the primary key of the table.How can I
reference it I have a query which SELECTs all the fields in the table WHERE
rptid = "reportname", but dispite trying many thing eg Me.name etc I can't
find the name. Thanks for help.
 
Back
Top