By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,299 Members | 1,141 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,299 IT Pros & Developers. It's quick & easy.

set titlle of report based on button clicked on in the main form

P: 9
I have one report with several buttons to open the report based on filters on the buttons. when button "A" is pressed, I want title of report to be "A"
when button "B" is clicked, title should be "B"
thanks
Jan 5 '15 #1

✓ answered by twinnyfo

Seth,

Good solution. I always forget about that option--which has been around forever--because I haven't had a need to use it.

Clearly the easier solution in this situation. Thanks!

Share this Question
Share on Google+
10 Replies


twinnyfo
Expert Mod 2.5K+
P: 3,482
Expand|Select|Wrap|Line Numbers
  1. Reports![ReportName].Caption
will change the name of the report in its window, but I think you may be talking about a Title that prints on your Report?

If this is the case, the easiest way I can think of is to have the Title generated when you set the filters.

After the report is opened, use VBA to change either a Text Box or Label based on the Filters. E.g., button A is clicked,

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "ReportName", , , "WHERE Conditions"
  2. Reports![ReportName].txtTitle = "This is Report A"
I think that should help. Let us know if you run across other snags.
Jan 5 '15 #2

P: 9
thank you for your responce
this is my code
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "RptUnion", acViewPreview, , "Check=-1"
  2. Reports![RptUnion].Title5 = "This is Report A"
title5 is an unbound textbox
there is no error message in the code but the text box is empty

thank you
dovid
Jan 5 '15 #3

twinnyfo
Expert Mod 2.5K+
P: 3,482
That was unexpected--although I had not tried that before. based on how Access uses all other Objects, one could only assume the same would work for reports......

Is there a way you could establish a Global Variable using TempVars()? This could hold a value, then the Control Source for that Text box could be the value of the Variable.

Your Code to open the report would be:

Expand|Select|Wrap|Line Numbers
  1. Dim strReportName As String
  2. strReportName = "This is Report A"
  3. TempVars.Add "ReportName", strReportName
  4. DoCmd.OpenReport "RptUnion", acViewPreview
Then, the Control Source for the Text box is:

Expand|Select|Wrap|Line Numbers
  1. = TempVars("ReportName")
Hope this hepps!
Jan 5 '15 #4

Seth Schrock
Expert 2.5K+
P: 2,951
Instead of using a Tempvar, I would just add an OpenArgs to the DoCmd.OpenReport command and then use the report's OnLoad event to set the value of Title5 to the value in the OpenArgs property.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "RptUnion", acViewPreview, , "Check = -1", , "This is Report A"
Then in the report's OnLoad event,
Expand|Select|Wrap|Line Numbers
  1. Me.Title5 = Me.OpenArgs
Jan 5 '15 #5

twinnyfo
Expert Mod 2.5K+
P: 3,482
Seth,

Good solution. I always forget about that option--which has been around forever--because I haven't had a need to use it.

Clearly the easier solution in this situation. Thanks!
Jan 5 '15 #6

P: 9
perfect, thanks for everything
dovid
Jan 5 '15 #7

twinnyfo
Expert Mod 2.5K+
P: 3,482
I would suggest selecting Post #5 as the answer for this thread....
Jan 6 '15 #8

twinnyfo
Expert Mod 2.5K+
P: 3,482
Your call to open the report would be:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "RptUnion", acViewPreview, , "Check = -1", , 1 'or 2 or 3
The title is set in the OnOpen event as well.
Jan 8 '15 #9

zmbd
Expert Mod 5K+
P: 5,397
<Split second question into its own thread>
Handle Multiple Reporting Options
Jan 8 '15 #10

P: 9
took me a bit to get it to work but it's perfect
learned a lot of new options
thanks for everything
dovid
Jan 8 '15 #11

Post your reply

Sign in to post your reply or Sign up for a free account.