Dynamic Titles on a form?

jrizzo

New member
Local time
Today, 02:50
Joined
Jul 9, 2001
Messages
6
hey all,
I'm trying to figure out how to get a dynamic title to work on a report. Here's what I want to do...
I have a form that contains eight buttons each representing a report. When the user clicks one of these buttons I have code to pass the correct sql WHERE clause to the report. My problem is I want to have a dynamic title on each report (I'm only using one report for all eight selections) depending on which button the user clicks. So, my question is how do you pass a parameter to a report. I hope this is enough info...if not let me know, I can try to put my code up here.

Thanks!
John
 
I would do it like this:

1. Declare a public string variable.
Public MyReptTitle as String
2. When the users clicks one of the buttons set the variable:

MyReptTitle = "Whatever Title You Like"
3. When The Report opens use the OnOpen vent to set the text of a label box.

Me!MyTitleLabel = MyReptTitle

Although I haven't tried it I am sure it will work.

Ian
 
Ian,

Thanks for the help, but I'm still having problems. I set it up the way you said and it still won't work. I have a form that has the buttons on it that the users click to run the report. It is here that I am passing the sql WHERE clause on to the report using the DoCmd. The report is where I need to dynamically change the title depending on what report was chosen to run. The way you said to do it will not work because the variable declared and assigned in the form is not available in the report. I hope I make sense.

Thanks and any more help would be most appreciated!
John
 
Sorry mate, of course!

You need to move the variable declaration out of the form and into a module so it is 'visible' by all the db's objects.

That should work.

Come back if not.

Ian
 
Another error in my code is that it should be

Me!MyTitleLabel.Caption = MyReptTitle
NOT
Me!MyTitleLabel = MyReptTitle

We live and learn more slowly with age!

Ian
 
if you didn;t know already public variables aren't declared with Dim they use Public so declare the variable like this:

Public MyReptTitle as String

Ian
 
Thanks,

I will try it as soon as possible. I'm kind of tied up with something right now and cannot get to it.

Thanks again and I'll let you know how I'm doing.
John
 
Ian,

Thanks so much...I just tried it and it worked. Duh...a module! I don't know why I didn't think of that. Thanks again!

John
 

Users who are viewing this thread

Back
Top Bottom