FindFirst Not Working

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
 
A

Allen Browne

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top