Runtime error 91

S

SF

Hi

I have the following code for updating SQL Server table connected through
ODBC. Evrytime I run this code, I received a runtime error # 91.



Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim Stg As String

Stg = "UPDATE tblProjectActivityNumber SET
tblProjectActivityNumber.Pr_ActivityNumber =" & Me.Pr_ActivityNumber
Stg = Stg & " WHERE (((tblProjectActivityNumber.Pr_ObjectID)=" &
Me.ProjectName & "));"

dbs.Execute Stg, dbFailOnError + dbSeeChanges
 
T

Tom Wickerath

In the Immediate Window, we can see that error 91 returns the following:

?error(91)
Object variable or With block variable not set

The reason you are getting this error is that you have declared dbs, but you
haven't set it yet. You need to add the following line of code (I recommend
after all the Dim statements):

Set dbs = CurrentDB()

You may also need to include quotes around the Me.ProjectName part, if this
is a text string. Something like this:

" WHERE (((tblProjectActivityNumber.Pr_ObjectID)= ' " & ProjectName & " ' ));"

At the end of your procedure, in an ExitProc section, you should make sure
to set this variable to nothing.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 

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

Code won't work 1
Error 3622 0
Excel workbook and printing 3
Code wont work 2
Data entry with Leban RTF 0
Exort set of queries to excel 2
Help with code 2
Help with This Code 2

Top