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

Programatically 'fill in' either a text box or label in a report

Status
Not open for further replies.

McLiguori

Technical User
Mar 27, 2003
90
IT
Hi all,

Is there a way to programatically 'fill in' a label or text box in a report?

In the following code (which I got from Spenny and modified slightly):

strDocName = "Status Actualis-UnitBatch"
DoCmd.OpenReport strDocName, acViewDesign
Set rpt = Reports(strDocName)
rpt.FilterOn = True
rpt.Filter = "Unit = '4500'"
DoCmd.Close acReport, strDocName, acSaveYes
DoCmd.OpenReport "Status Actualis-UnitBatch", acViewPreview

I would like to add code that would fill in a text box or label in the report with some text. I have tried:

(Text59 being the name of the unbound text box I created)
Text59 = "Denver"
Text59 = "= Denver"
Text59 = "= 'Denver'"

On most of these I get no error message, but the text I want does not appear in box.

Perhaps the way to go is a label. I have tried similar combinations of code for a label (using Label59), but nothing has worked.

Your help is greatly appreciated.

McLigs


 
OnPrint event of the report section containing your unbound textbox, you could include something along the lines of:

Me.Text59 = "Denver"

Let them hate - so long as they fear... Lucius Accius
 
I don't know why anyone would want to use code to open a report in design view. The 7 lines of code could be written in 2 lines and be run much faster.
Code:
   strDocName = "Status Actualis-UnitBatch"
   DoCmd.OpenReport strDocName, acViewPreview, , "Unit = '4500'"

There are lots of methods for having values displayed in the report. Each method might be better based on the context it is used like where the value comes from (table, code, control on form,...) The method might also depend on the version of Access. I would probably send in the value in the OpenArgs and then use code in the On Format event of the section containing the control you want to update.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top