troubleshootin before_update

  • Thread starter Thread starter Lee Taylor-Vaughan
  • Start date Start date
L

Lee Taylor-Vaughan

I am trying to code a control (textbox) under its before_update to check the
recordset to see an entry has already been entered to the DB.

I am getting some peculiar results. (code posted below)

-if I include Not before the .nomatch the code does not execute--it just
skips right through the code and then i get a duplicate error message when I
am done entering the record.
-if i take out the Not before the .nomatch then every time i enter a record
the code execute and it always tells me that there is a record in the
database with this control number, even if it doesnt exist in the record
set.
-i am not able to click cancel and have the record display.. i get Err.3021,
"no current record", why is this when the record does exist....

please help

Lee




Private Sub ControlNumberID_BeforeUpdate(Cancel As Integer)
On Error GoTo CNError

If Not IsNull(Me.ControlNumberID) Then
With Me.RecordsetClone
.FindFirst "[ControlNumberID]=" & "'" & Me![ControlNumberID] &
"'"
If .NoMatch Then
If MsgBox("There is already a record entered in the database
with this Control Number." _
& Chr(13) & "Click the 'OK' button to go to this record
now; " _
& "Click cancel to clear your entry and to enter a
different Control Number." _
, vbOKCancel, "Mission Already Exists") = vbOK Then
Cancel = True
Me.Undo
Me.Bookmark = .Bookmark
Else
Cancel = True
Me.ControlNumberID.Undo

End If
End If
End With
End If

ExitSub:
Exit Sub

CNError:
MsgBox Err.Number & " " & Err.Description
Resume ExitSub

End Sub
 
You seem to have a similar problem that i am. Check
out "Adding a pop up warning" foem yesterday. I haven't
tried it yet, bu tif it works, it might help you too.
 
Back
Top