post last update field after Confirming Save

dmeehanjr

New member
Local time
Today, 02:29
Joined
Feb 18, 2010
Messages
9
I have a "Confirm Save' msgbox in beforeupdate event of a form. I also need to value the 'lastUpdated' field on form with Now(), but loops me back into confirming Save. How/where can i value the update date without looping into beforeUpdate event? (I tried valuing lastUpdate in afterupdate event, but still takes me to beforeUpdate event for that update).

would i need to update the lastUpdate field with a query, so as not to make form dirty again?

thanks!
Don
 
As part of the confirmation process, if the user opts to save the changes put a line of code in it that sets the Update field to Now(). It might look something like;
Code:
        If MsgBox("Do you wish to update this record", vbYesNo) = vbYes Then
            Me.YourUpdateField = Now()
        Else
            Cancel = True
            Exit Sub
        End If

Also, unless you specifically need a time component on your Update Value use Date() in preference to Now()
 
You've apparently got an error in your code, if it's doing this. It should be in the Form_BeforeUpdate event, but it shouldn't re-dirty the Form, since the Record is not quite saved at that point. This is a hack I use to do this very thing:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)

Me.LastUpdated = Now()

If Not (Me.NewRecord) Then
 If MsgBox("Would You Like To Save The Changes To This Record?", vbQuestion + vbYesNo + vbDefaultButton1, "Save Changes to Record ???") = vbNo Then
  Me.Undo
 End If
Else
 If MsgBox("Would You Like To Save This New Record?", vbQuestion + vbYesNo + vbDefaultButton1, "Save This Record ???") = vbNo Then
  Me.Undo
 End If
End If

End Sub
Linq ;0)>
 
thanks - I had tried, but that seems to trigger the beforeUpdate event again, and get the msgbox again.
 
think i got it! had afterupdate doing it also..thanks for your help and eyes!
 
Glad you got it working!

Good luck on your project!

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom