I have a form that lets the user edit the values in a lookup table. The form is bound to a table and has one textbox on it. The record nav buttons are enabled. On the top half of the form, I have a listbox showing all the records in the table. The user can double-click the listbox to jump to that record via this code:
Expand|Select|Wrap|Line Numbers
- Me.RecordsetClone.FindFirst "[cSalut] = '" & Trim(Nz(Me.lstSaluts)) & "'"
- If Not Me.RecordsetClone.EOF Then Me.Bookmark = Me.RecordsetClone.Bookmark
- Me.txtSalut.SetFocus
Expand|Select|Wrap|Line Numbers
- ' prevent user from changing value to one already in the list
- If DCount("[cSalut]", "[Saluts]", "[cSalut] = '" & Trim$(Nz(Me.txtSalut)) & "'") > 0 Then
- MsgBox "That Salutation already exists."
- Cancel = -1
- End If
- ' prevent a blank record
- If Len(Trim$(Nz(Me.txtSalut))) = 0 Then
- MsgBox "The Salutation field cannot be blank."
- Cancel = -1
- End If
- The user edits a record by clearing the textbox;
- The user then double-clicks the listbox
- The BeforeUpdate fires, but the textbox is blank so it gets cancelled
- However, the DblClick code still finishes and I get a No Current Record error on the Recordset.Bookmark line.
So I'm wondering if there's any way to tell whether or not BeforeUpdate failed.
Thoughts?
Thanks