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

Change a text box within a report based on form calling the report?

Status
Not open for further replies.

Junior1544

Technical User
Apr 20, 2001
1,267
US
I have a report that is used for different things based on what form is calling it... (I just learned how to do most of this, so i'm tring to rework some of my database to run better, with fewer objects...)

what i want to do, is change a text box(that is the title of the report) based on the form calling it... i have tried making reference to the data and couldn't get that to work... i have a hidden text box on each form with what i would like the title to be, and i'm tring to figure out how to get that onto the title of the form... any idea's??

--Junior JHauge@jmjpc.net
Life is change. To deny change is to deny life.
 
If I'm understanding you correctly, there's a simple solution I use in several forms/reports in my databases. I'll pre-qualify (example): I have a form used to facilitate running a report. The form has combo boxes with choices pre-defined; user selects the criteria for the report via these "drop-down" items. (i.e. choose to run report on YEAR=2000,2001; CITY=A,B,C)
When the report is run, the text box in my report/page header is set according to the values specified on the form at run-time. Since you've already got a hidden text box on your form holding the value you want to use in your header, here's one way to do it:

In the design view of the report, click on the Report Header bar, and view it's properties. Click on the EVENTS tab, the first item labeled On Format, and click the build button for that event. In the VB editor window, you can type something as simple as this:

With Forms!FormName
Me.TxtBox1 = .FormTxtBoxA
End With

[where FormName = the name of the form that contains the hidden text box; Me.TxtBox1 = the text box on your report header; .FormTxtBoxA = the hiddent text box on your form]

You may be trying to do some other things I'm not picking up on in your question which would require some other parameter settings or additional programming; also may vary depending on your form's use/functionality. At any rate, hope this helps.

-hmm
 
Hi, you could do something like this as well:

Create an option group using the wizard and list out the number of report labels you want to use - 5 choices, 5 buttons. Assume the frame is named frame50 and the form is named FrmYourFormName.

In the report header place a label where you want it and with no caption (an empty label). Name the label LblCaption.

Right click on the report header, properties, event - on format and go to the code builder. Use a select case statement which would look something like this:

Private Sub ReportHeader_Format(Cancel As Integer,FormatCount As Integer)
Select Case Forms!FrmYourFormName.Frame50
Case is = 1 'The value of the first option button.
me.lblcaption = "First Report Title"
Case is = 2 'The value of the second option button.
me.lblcaption = "Second Report Title" ' and so on

End select

End Sub

What this is doing is looking at the button selected in your option group on print to determine what the label should read. It does require that the form the option group is on stay open on print.

Hope that helps.








 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top