I have a form that has a wizard-generated search box to find a particular record. This particular form also has a field that automatically logs "Now()" when you change records. The problem is that sometimes when you use the search box to locate a particular record, if you make a very minimal change, such as only checking a checkbox, or enter a field & make no changes (sometimes), you get an error when you try to quickly leave the record using the search box...but not every time. You can go to "next record" with no problems at all, but sometimes searching for another record with the search field generates the following error:
If you Debug, it goes to this code, but I am not sure what is wrong with it...
Just as an FYI, ALL the code for the form is attached below. What I am TRYING to do is have the form notate the date & time the record was updated any time the form or either of its subforms is changed. (BTW...it does NOT seem to make this notation for the subform updates) I suspect I am not doing this quite right, but I do not know how to fix it. Can anyone help?
Here is the form code:
Thanks for any suggestions!
Runtime error '3020'
Update or CancelUpdate without AddNew or Edit
If you Debug, it goes to this code, but I am not sure what is wrong with it...
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.txtRecordUpdated = Now()
End Sub
Just as an FYI, ALL the code for the form is attached below. What I am TRYING to do is have the form notate the date & time the record was updated any time the form or either of its subforms is changed. (BTW...it does NOT seem to make this notation for the subform updates) I suspect I am not doing this quite right, but I do not know how to fix it. Can anyone help?
Here is the form code:
Code:
Option Compare Database
Option Explicit
Private Sub cboNameSearch_AfterUpdate()
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[SSN] = '" & Me![cboNameSearch] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark
Me.cboNameSearch = Null
End Sub
Private Sub cboSSNSearch_AfterUpdate()
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[SSN] = '" & Me![cboSSNSearch] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark
Me.cboSSNSearch = Null
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.txtRecordUpdated = Now()
End Sub
Private Sub subfrmActions_Exit(Cancel As Integer)
Me.txtRecordUpdated = Now()
End Sub
Private Sub subfrmRoster_Exit(Cancel As Integer)
Me.txtRecordUpdated = Now()
End Sub
Thanks for any suggestions!