troubleshooting Question

Insert Into and use Current Date

Avatar of pdvsa
pdvsaFlag for United States of America asked on
Microsoft Access
7 Comments1 Solution49 ViewsLast Modified:
Experts, I am using the below code to update a table.  I need to adjust it.  The issue is fldDate is being updated with the value of [Date] but I need it to update to the current date.  I have a field named [Date] and that is the issue. The “VALUES (#" & Format(Date, "m\/d\/yyyy") ” part in the code below would need to be adjusted to insert the current date (not the date found in the field [Date]). I know that [Date] is not ideal name but I am importing from excel.  I do not want to change the name.  thank you....

Private Sub cboStatus2_AfterUpdate()
    Dim strSQL As String
     DoCmd.RunCommand acCmdSaveRecord
  strSQL = "INSERT INTO tblStatusHistory (fldDate, id, Buy_CP, Batch, TP_No, Status2) VALUES (#" & Format(Date, "m\/d\/yyyy") & "#," & Me!ID & ",'" & Me!Buy_CP & "','" & Me!Batch & "','" & Me!Trade_No & "','" & Me!cboStatus2.Column(1) & "')"
  
  'Debug.Print strSQL
  
  DoCmd.SetWarnings False
  DoCmd.RunSQL strSQL
  DoCmd.SetWarnings True
  
End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros