update table using VBA Code (1 Viewer)

ollyhutsy

New member
Local time
Today, 08:21
Joined
Nov 13, 2019
Messages
5
I am currently trying to run an update query through VBA Code and I cant seem to get it to work, Don't know if theres just a slight error or I'm miles off.



Code:
Dim db As DAO.Database, sSQL As String

Set db = CurrentDb
sSQL = "UPDATE [Job Detail] SET [StatusID] = 5 " & _
     " WHERE [Document Name] = '" & Me.[Document Name] & "' AND [Job Complete] = 0"

db.Execute strSQL, dbFailOnError
any suggestions?
 

June7

AWF VIP
Local time
Yesterday, 23:21
Joined
Mar 9, 2014
Messages
5,488
What does "can't seem to get it to work" mean - error message, wrong result, nothing happens?

You declare and set variable sSQL yet you Execute strSQL.

You should probably add Option Explicit to the module header. It will expose errors like this.
 

ollyhutsy

New member
Local time
Today, 08:21
Joined
Nov 13, 2019
Messages
5
my bad, 'Query is corrupt' is the error message I'm getting.
 

June7

AWF VIP
Local time
Yesterday, 23:21
Joined
Mar 9, 2014
Messages
5,488
I may have edited my previous post after you read it. Review again.

Not message I would expect for this error.
 

June7

AWF VIP
Local time
Yesterday, 23:21
Joined
Mar 9, 2014
Messages
5,488
Rats, keep forgetting about that bug. Thanks, Colin.
 

Users who are viewing this thread

Top Bottom