Avatar of pdvsa
Flag for United States of America

asked on 

Insert Into and use Current Date

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

Open in new window

Microsoft Access

Avatar of undefined
Last Comment

8/22/2022 - Mon