Help with correcting calculation (1 Viewer)

Spam808

Registered User.
Local time
Yesterday, 19:51
Joined
Dec 3, 2018
Messages
55
I need help incorporating another textbox thats located in a different form to include in part of the calculation. My formula is written like this, but I understand this causing the problem "[Forms]![001Form]![txtAmount]." I probably didn't right it correctly.

=Nz(([Forms]![001Form]![txtAmount])*1099/Nz([CellA1])/Nz([CellA2]))
 

June7

AWF VIP
Local time
Yesterday, 18:51
Joined
Mar 9, 2014
Messages
5,470
As long as that form is open and not used as a subform, that expression should work.

What should Nz() return if the fields or result are Null? Remember, division by zero will error.

If you want to provide db for analysis, follow instructions at bottom of my post.
 

Spam808

Registered User.
Local time
Yesterday, 19:51
Joined
Dec 3, 2018
Messages
55
As long as that form is open and not used as a subform, that expression should work.

What should Nz() return if the fields or result are Null? Remember, division by zero will error.

If you want to provide db for analysis, follow instructions at bottom of my post.

Cool, thank you...Is there a way to make settings so the other form doesnt need to be opend?
 

June7

AWF VIP
Local time
Yesterday, 18:51
Joined
Mar 9, 2014
Messages
5,470
If you need value from a form it must be open. Otherwise, maybe domain aggregate function would provide what you need or a VBA custom function.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 21:51
Joined
Feb 28, 2001
Messages
27,179
Spam808 - June7's answer is correct. So the question is, on that other form, how does the form get the value to be displayed? If it is computed on that form, how is it computed and from what? If it is just displayed, that's a different question.

You might need something as simple as a DLookup but if there are multiple inputs to a computation then you might need more.

Remember that if a form isn't open, it isn't in memory. The syntax you used (that starts with [Forms]) implicitly is looking in memory, because the [Forms] collection only contains open forms; no closed forms are there. To read the contents of a control, that control has to be instantiated by OPENING and LOADING the form that contains it.

Further, that strategy is dangerous in another way. Forms are independent from each other with the one exception being a parent-child form (or if you prefer, a main/sub form) situation. If both forms have the possibility to navigate to different records, there is no guarantee they will be synchronized to the same record unless they are explicitly linked, and that can only easily occur with parent/child form situations.
 

Users who are viewing this thread

Top Bottom