.findfirst doesnt find the first!

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

Lee Taylor-Vaughan

Help!

the code below does not find the first record with the value
the controlnumberid field is a text field input mask is ##-######

code below, please help.

thanks

lee

CODE:
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 Not .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.") = 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
 
Hi Lee,
You need to format your criteria as text:

.FindFirst "[ControlNumberID] = '" & Me![ControlNumberID] & "'"

after the = sign use single quote ' before your double quote "
end your criteria with double quote, single quote, double quote "'"

There are other ways of specifying text strings in criteria which may be
found in online help.

Hope this helps
regards
 
Back
Top