BeforeUpdate errors after changing record with bookmark.

John Tompa

New member
Local time
Today, 01:10
Joined
Mar 14, 2008
Messages
9
I am running Access 2000.

I have a form which has an beforeupdate event to set a time stamp:
I also have a combo box with a goto a record using the recordsetclone & bookmark.
If I change anything in the displayed record, the GoTo combo box errors with the message "Update or CancelUpdate without AddNew or Edit". Andwering OK makes me stay at the same record. I have to press escape to be able to continue.

However by moving to a new record by the navigation buttons, there is no error & the new record is gone to.

Here is the code:
for the combobox "AllerNom":
Private Sub AllerNom_AfterUpdate()
With Me.RecordsetClone
.MoveLast
.FindFirst "[ID] = " & Me![AllerNom]
Me.Bookmark = .Bookmark
End With
End Sub

For the form beforeupdate
Private Sub Form_BeforeUpdate(Cancel As Integer)
MiseAJourGenerale
End Sub

and the sub MiseAJourGenerale
Private Sub MiseAJourGenerale()
Me.MaJ = Now()
End Sub

On answering debig the code Me.MaJ = Now() is highlighted.

Any ideas?

Thank you

John Tompa
 
Before Update Error

Try changing the line to Me.Maj.Value = Now()
 
Before Update Error

or Me!MaJ = Now()
 
Thank you for these two suggestions apr pillai.
I tried them both & unfortunately neither worked.
I followed something else up. After I had posted my question, the system came up with some similar posts. One of them suggested moving to the next record to close & write the current record then to return to the previous to be back at the original record. Then do the Bookmark RecordClone code. This works. The modified code is now:

Private Sub AllerNom_AfterUpdate()
DoCmd.GoToRecord , , acNext ' make sure record is updated first
DoCmd.GoToRecord , , acPrevious

With Me.RecordsetClone
.MoveLast
.FindFirst "[ID] = " & Me![AllerNom]
Me.Bookmark = .Bookmark
End With
End Sub

I'm not quite sure why & I haven't done any thoriugh testing, but it seems to work.
 

Users who are viewing this thread

Back
Top Bottom