Access World Forums

Access World Forums (https://www.access-programmers.co.uk/forums/index.php)
-   Reports (https://www.access-programmers.co.uk/forums/forumdisplay.php?f=10)
-   -   Automatically Update Textbox Value on Report Load (https://www.access-programmers.co.uk/forums/showthread.php?t=301438)

vagues0ul 09-13-2018 09:43 AM

Automatically Update Textbox Value on Report Load
 
I am having issue while updating textbox value on report load. I want the textbox values to load automatically instead of clicking on it while the reports load because on click every box display its value to all the present box on the report.

this is my script

Private Sub Text148_Click()
Text148.Text = Round((m1totals.Value / markstotal.Value) * 100, 2)

End Sub


i dont want it to be done ONCLICK but on report load

June7 09-13-2018 10:31 AM

Re: Automatically Update Textbox Value on Report Load
 
Why using Text property? Probably really want to set Value but this cannot be done with textbox on report. Since Value is default, no need to type it.

If you are trying to save to table - why? Why don't you put expression in ControlSource and calculate when needed?

Really not clear what you are trying to accomplish.

Pat Hartman 09-13-2018 12:22 PM

Re: Automatically Update Textbox Value on Report Load
 
The Load property runs ONCE when the report is loaded. Your expression appears to depend on data from the report's RecordSource. That means that you want the code to run for each row so the Format event would be better.

Additional comments on syntax:

In Access forms/reports, the .value property is the default and the .text property is only available while the control has the focus so I can't imagine this working.

For efficiency, use Me.controlname rather than controlname.value

Me. is available ONLY in the code module of the form/report. It qualifies the variable so that Access knows where it is defined. It also provides intellisense. See what happens when you type:
Me.controlname.
you'll get a list of properties and methods

And finally, it is really poor practice to leave controls with the default name. BEFORE you add code to events or reference a control, always rename it so that it has a meaningful name. When you drag controls from the bound RecordSource, Access gives them the same name as the ControlSource. Common practice is to rename them with a prefix such as txt or cbo or cmd.


All times are GMT -8. The time now is 06:37 PM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World