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

I want to populate an Access Report Textbox using a Variable from Code

Status
Not open for further replies.

JCG4LOM

Technical User
Jul 10, 2003
18
0
0
US
I am looking to populate a report textbox using a value contained ina variable of code. The only way I have found to do anything close to this is using a label. Since, I need to use the value within the report to calculate other report values, I would prefer to use a textbox.

Here is the code I have to populate labels. Anyone who can help me do this with textboxes, it is appreciated.

DoCmd.OpenReport strReportName, acViewDesign ' open report in design view
With Reports!rptRORRatio
.lblIncentivePaidLookup.Caption = lblPaidFeesAccumulator ' populate fields
.lblFundsAvgNALookup.Caption = dblFundsAvgNA
.lblLPsAvgNALookup.Caption = dblLPsAvgNA
.lblDate.Caption = strEndDate
End With

Thanks,
Jason
 
Hi JCG4LOM,

Not sure I fully follow what you are doing, but you can set a textbox to a function, =MyFunc(), say, and that function can return any value you like.

Enjoy,
Tony
 
Thanks Tony, but I am not sure that is what I need. I have code to open the report in design view. I then want to set the values of textboxes to be the values of variables I have calculated through code. The example code I gave sets label values, not textbox values. I know the following:

Excel you set a cell value with activecell.value = variable
VB Forms you set with textboxname.text = variable
Access Report Labels labelname.caption = variable

I am looking for the equivalent for an Access Report Textbox as neither textboxname.value = variable, textboxname.text = variable, textboxname.source = variable, or textboxname.caption = variable have worked.

Hopefully, someone knows how to do this.

Jason
 
Hi Jason,

Sorry, I didn't register the bit about design view. I thought you were talking about previewing/printing, and I am a bit confused about why you want to design the form in code, but anyway ..

Textbox contents are defined in the Control Source so you need to use ...

Code:
.TextBoxName.ControlSource = Value

.. the format of it depends on what exactly you are putting there. If your variable contains a literal you want to use, you'll need to put
Code:
"=""" & variable & """"
; if it contains a field name then use it as is.

Enjoy,
Tony
 
Thanks Tony, that worked perfectly for my needs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top