Use "after update" to open form

S

scubadiver

Hello,

I have an unbound text box to calculate the total hours. When the total is
greater than 36 I would like to open a new form for that record.

In the "after update" event I have the following code:

If Me.HrsSum > 36 Then DoCmd.OpenForm "Comment", , , "RecordID = " &
Me.RecordID & ""

yet nothing happens.

Cheers!
 
A

Arvin Meyer [MVP]

The after update event only happens when you update the control, not when
code does. What you can do is to add your code to the after update event of
the controls which contribute to the calculated control.
 
R

ruralguy via AccessMonster.com

If the ControlSource of your unbound text box is your formula then *no*
AfterUpdate event is generated. That event is only generated when there is
user input to a control.
 
S

scubadiver

thanks for the heads up!




ruralguy via AccessMonster.com said:
If the ControlSource of your unbound text box is your formula then *no*
AfterUpdate event is generated. That event is only generated when there is
user input to a control.
 
C

Carl Rapson

If the Control Source of the text box is an expression (formula), you don't
have access to the actual value resulting from the expression. You'll need
to perform the same calculation again in your code to get the value.

Carl Rapson
 
S

scubadiver

The following in the control source

=[HrsWrk_basic]+[HrsWrk_ID1]+[HrsWrk_ID2]+[HrsWrk_ID3]
 
S

scubadiver

For each of the three controls which make up the calculation I have inserted
the code. The code works but I need to refresh the record before the
"comments" form opens so other information from the record is shown.

How can I do this?
 
Top