Trouble Shoot VB Code error 3301

K

Kevin Baker

Hi Everyone,

I'm using the following code to update a field in on my form, however, I get
the error code 3301 from the Set RS statement. Anyone see my problem?

Private Sub Date_AfterUpdate()

Set rs = CurrentDb.OpenRecordset("PONUMBER", dbopendynaset)

rs.MoveFirst

myval = rs("LastNo")
If myval = 9899 Then
myval = 9700
Else
myval = myval + 1
End If
PONumber = myval
rs.edit
rs("lastno") = myval
rs.Update

Set rs = Nothing
End Sub

Thanks,
Kevin
 
G

Guest

Unless rs is a global defined elsewhere, you need to declare it:
Dim rs as DAO.Recordset
 

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

Top