Avatar of Fordraiders
FordraidersFlag for United States of America asked on

edit a record using a date variable in the sql statement

access 2010  vba

in code prior to trying to do this..

I have a table linked via sql server   "dbo_t_nsc_trackcode_trans_time_entry"
in this table i have a value for lookup. [opened_at]  a date field


I'm trying to update a record in this table above.
In the sql string  
g =  date

Global g As Date
d = now()
Forms!NSC_DataEntry.txtReOpened = d
g = Forms!NSC_DataEntry.txtReOpened  





If m = True Then
           Dim db1 As DAO.Database
           Dim rst1 As DAO.Recordset
           Dim strSQL1 As String
           Set db1 = CurrentDb()
           strSQL1 = "SELECT [nsc_id_ref], [opened_at], [InProgress_or_closed_at] FROM [dbo_t_nsc_trackcode_trans_time_entry] where [opened_at] = '" & g & "' "
           Set rst1 = db1.OpenRecordset(strSQL1, dbOpenDynaset)
          ' Dim q As DAO.Recordset
          ' Set q = CurrentDb.OpenRecordset("SELECT * FROM [dbo_t_nsc_trackcode_trans_time_entry] where [opened_at] = '" & g & "'", dbOpenDynaset, dbSeeChanges)
           rs1.Edit
           rs1![InProgress_or_Closed_at] = Now()
           Forms!NSC_DataEntry.txtReOpened = ""
         End If

Open in new window

Microsoft AccessVBA

Avatar of undefined
Last Comment
Gustav Brock

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Gustav Brock

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
Fordraiders

Thanks sorry for the delay
Gustav Brock

You are welcome!

/gustav
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy