Update SQL Table Using Pass-through Query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

It's been many years since I have had to manipulate SQL data through VBA code
in Access and I don't remember much.

I need to update the PwdDate field in a SQL server table (tAccounts_test)
through a query when certain criteria are met. Following is the code I am
trying to use to do the actual update, but it doesn't work. Please, can
someone give me the proper syntax?

******

strSql = "UPDATE dbo.tAccounts_test SET PwdDate = '01/01/2000' WHERE
UserID = '" & glUserID & "'"

rstPwd.Open strSql, CPwd, adOpenStatic, adLockOptimistic

******

Thank you.
 
Hi,
you have to pass date as #mm/dd/yyyy#
so it should be:
PwdDate = #01/01/2000#
also you don't need to open recordset, but just execute SQL:
CPwd.execute strSql

assuming that CPwd is a connection object
 
Back
Top