Unbound values and triggering events

Dave E

Registered User.
Local time
Today, 12:48
Joined
Sep 23, 2019
Messages
140
Hi All,

I have a main form which contains 2 bound controls showing height and spread.
Beside each of these is a button which opens a pop-up form ('Measures') and the value of the corresponding bound control (height or spread' in inches)is sent to an unbound control on the pop-up form. So far, so good.

Now, on the pop-up form (Measures), there are four unbound controls.
1, ImpInch, which gets its value from the main form.
2, Impfeet, which will hold the calculated value of Impinch/12
3, Metricmm, which will hold the calcualted value of ImpInch * 25.4
4, Metricm, wich will hold the calculated value of Metricmm/1000

The calculations are in code and in the OnOpen event on the pop-up but, apart from the value from the main form appearing on the pop-up form, the calulations don't get done.

If I move all the calculations to a button on the pop-up form, it works, but it's not what I want.

I've tried, OnLoad, OnOpen, On Activate, OnGotFocus to no avail.

I'm hoping to use the pop-up form as a ready converter for any of the four unbound values in time but not being able to get the calcs done automatically as the pop-up opens is annoying me.

Any ideas?

Regards

DaveE
 
use the pop-up form's load event to calculate,
remove first all expression from the textboxes, ie:

=impInch/12
=ImpInh *25.4

etc..

Private Sub Form_Load()
Me.ImpInch = Forms!theMainForm!ControlName
Me.ImpFeet = Me.ImpInch/12
Me.Metricmm = Me.ImpInch * 25.4
Me.Metriccm = Me.ImpInch * 2.54
End Sub
 
Hi arnelgp,

There are no calculations in the unbound fields, they're done in code in an event, if I can find one that works. I put breakpoints in the event ONLoad, after the code, but it doesn't stop. It seems that OnLoad, OnOpen or OnActivate won't work with calculated unbound controls.
 
maybe you should rebuild your pop-up form.
I tried my own pop-up, (pop, modal), and the calculation on the Load event fires.
 
Thanks, I'll try that tomorrow and let you know...

DaveE
 
Away from my computer at the moment but you could set each of the unbound textboxes control source directly to reference the main form:

Forms!MainFormNameHere!ControlNameHere

Then in the next:

Forms!MainFormNameHere!ControlNameHere / 12

Etc
That way you don’t have to rely on form events?


Sent from my iPhone using Tapatalk
 
Hello nhorton79,

Thanks for that. I have thought about doing it that way but then I extended to function, to using the form with the 4 unbound controls of each measurement type in a way that allows me to enter a value in any of the 4 and get the conversions in the other 3 controls (After Update).

That bit works OK but wouldn't work once I'd entered any parameters into them.

Thanks for the thought though.

Dave E
 
OK,

OnLoadProblem.accdb uploaded

Here is a test db with the relevant objects. It is working, or not working, as it is on the main db.

Hope you can help.

DaveE
 

Attachments

Yes, it works, thank you. I'm puzzled as to why the IsNothing() function isn't working for you. Was it the reason the code wasn't running on the OnLoad event?

Thanks again, and to all who offered help.

Kind Regards

DaveE
 

Users who are viewing this thread

Back
Top Bottom