Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run Update Query Using VBA 1

Status
Not open for further replies.

crisis2007

Technical User
Apr 2, 2007
114
US
I have been struggling with this for over an hour. I am trying to run an update query in vba but continuously receive a message that the syntax is incorrect. I suspect it has to do with the part about the current date. I am just not getting it. Any help is very appreciated!


Dim strSQL As String
strSQL = "UPDATE T_Employee SET T_Employee.AccessLevel = 0"
strSQL = strSQL & "WHERE T_Employee.TempEndDate < Date()"
CurrentDb.Execute strSQL
 
strSQL = strSQL & "[highlight] [/highlight]WHERE T_Employee.TempEndDate < Date()"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
My goodness, definitely not where I was looking. Thank you so very much!
 
or:
Code:
[blue]strSQL = "UPDATE T_Employee SET T_Employee.AccessLevel = 0[COLOR=black silver] [/color]"[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 

...or, do yourself a favor and do:
Code:
Dim strSQL As String
strSQL = "UPDATE T_Employee SET T_Employee.AccessLevel = 0 "
strSQL = strSQL & " WHERE T_Employee.TempEndDate < Date()"[blue]
Debug.Print strSQL[/blue]
CurrentDb.Execute strSQL
and see in the Immediate Window what your DB gets from you. Most of the time you will see your error.

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top