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
ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Fordraiders
Fordraiders
Flag of United States of America image

ASKER

Thanks sorry for the delay
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

You are welcome!

/gustav
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo