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

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
 
B

Bob Quintal

:
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.
 
P

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.- Hide quoted text -

- Show quoted text -

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top