Help! code in "Form_AfterUpdate()" prevents saving of record

  • Thread starter Thread starter plh
  • Start date Start date
P

plh

Access 2003 SP3:
I have the following code:

Private Sub Form_AfterUpdate()
Dim dtToday As Date
With Me
If .chkProg2Master.Value + .chkProgramOK.Value
+ .chkSetUpDocsOK.Value + .chkToolingOK.Value = -4 Then
dtToday = Now()
.txtCompletedDate.Format = "Short Date"
.txtCompletedDate = dtToday
Else
.txtCompletedDate.Value = ""
End If
End With
End Sub

When this fires, ".txtCompletedDate.Value" updates on the screen
appropriately when I click in another record or on the pencil
indicator, but Access prevents me from saving the record, in that the
pencil indicator does not go away, and if I close the form, I get the
"You can't save this record at this time" message. This seems like it
shuld be a no-brainer. Can anyone tell me what gives? I would
certainly appreciate it!
Thank You,
-plh
 
:
Access 2003 SP3:
I have the following code:

Private Sub Form_AfterUpdate()
Dim dtToday As Date
With Me
If .chkProg2Master.Value + .chkProgramOK.Value
+ .chkSetUpDocsOK.Value + .chkToolingOK.Value = -4 Then
dtToday = Now()
.txtCompletedDate.Format = "Short Date"
.txtCompletedDate = dtToday
Else
.txtCompletedDate.Value = ""
End If
End With
End Sub

When this fires, ".txtCompletedDate.Value" updates on the screen
appropriately when I click in another record or on the pencil
indicator, but Access prevents me from saving the record, in that
the pencil indicator does not go away, and if I close the form, I
get the "You can't save this record at this time" message. This
seems like it shuld be a no-brainer. Can anyone tell me what
gives? I would certainly appreciate it!
Thank You,
-plh

What gives? easy, the After Update event fires after the form is
written to disk. In your example, after writing the data to disk, you
change that data, forcing another write to disk, which retriggers the
after update event, which changes the data forcing forcing another
write to disk, which retriggers....

Fix: move the code to the before_update event for the form.
 
:








What gives? easy, the After Update event fires after the form is
written to disk. In your example, after writing the data to disk, you
change that data, forcing another write to disk, which retriggers the
after update event, which changes the data forcing forcing another
write to disk, which retriggers....

Fix: move the code to the before_update event for the form.- Hide quoted text -

- Show quoted text -

You are right that was easy. Thank You!
-plh
 
Back
Top