FindFirst Not Working

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have the following code and it doesn't seem to work.

If anyone can please help.

stWhere = "([Keycode]=""" & stKeycode & """) And
([Description]=""" & stDescrip _
& """)"
On Error Resume Next
rs.MoveFirst
rs.FindFirst stWhere
If rs.NoMatch Then
rs.addnew
rs.fields(0) = stKeycode
rs.fields(1) = stBrandNo
rs.fields(2) = stDescrip
rs.fields(3) = stColour
rs.fields(4) = stCost
rs.fields(5) = stSell
rs.Update
End If

Thanks
 
Remove the:
On Error Resume Next
so Access can notify you if anything goes wrong.

Until you debug it, get Access to notify you if a match was found:
If rs.NoMatch Then
'existing code here.
Else
Debug.Print stKeycode & " found"
End If

Make sure you have this line at the top of your module:
Option Explicit

If KeyCode is a Number field (not a Text field when you open the table in
design view), drop the extra quotes.
 
Back
Top