Update Formulas upon opening Form

bb29829

Registered User.
Local time
Today, 03:39
Joined
Dec 4, 2014
Messages
17
I have a form with a number of input fields. Once the data is input, other fields calculate based on the value of the input. Every time I close the form and re-open, I have to click in the calculating field in order for the values to come back. I know I should be using a different event type but I am not sure which. Can anyone assist? Thanks!
 
Put the formulas in the ControlSource property of the textbox.
Code:
=[Quantity] * [Price]
 
I have input box called KNOWLEDGE1 where I put in a value of 1 to 12. Then I have a another box with the following code:

If KNOWLEDGE1 = 1 Then
KF1 = "30"
ElseIf KNOWLEDGE1 = 2 Then
KF1 = "53"
ElseIf KNOWLEDGE1 = 3 Then
KF1 = "75"
ElseIf KNOWLEDGE1 = 4 Then
KF1 = "98"
ElseIf KNOWLEDGE1 = 5 Then
KF1 = "120"
ElseIf KNOWLEDGE1 = 6 Then
KF1 = "143"
ElseIf KNOWLEDGE1 = 7 Then
KF1 = "165"
ElseIf KNOWLEDGE1 = 8 Then
KF1 = "188"
ElseIf KNOWLEDGE1 = 9 Then
KF1 = "210"
ElseIf KNOWLEDGE1 = 10 Then
KF1 = "233"
ElseIf KNOWLEDGE1 = 11 Then
KF1 = "255"
ElseIf KNOWLEDGE1 = 12 Then
KF1 = "278"
ElseIf KNOWLEDGE1 = 12 Then
KF1 = "300"
Else
KF1 = "0"
End If
End Sub

It will calc but I have to click the box each time I go into the form. How can I get it to calc without having to click on the box?
 
Write a custom recalculation procedure for your form. Then call that procedure from the form's Current event, AND from any control's AfterUpdate event that will influence that outcome. Consider the following code . . .
Code:
private sub form_current()
   ResetForm
end sub

private sub somecontrol_afterupdate()
   ResetForm
end sub

sub ResetForm
[COLOR="Green"]   'your custom code to recalculate controls on the form[/COLOR]
end sub
This is a common pattern if you need to update the display of your form when you load a new record AND when you update controls.
Hope this helps,
 

Users who are viewing this thread

Back
Top Bottom