I'm trying to run the VBA below to delete table records based on a certain date.
The date is selected by the user in a form control then set to TempVars using TempVars!tmpEndDate = Me.txtEndDate.Value
The value of strSQL is Delete * From [tblBalance] WHERE [TransactionDate] = 4/4/2023
I believe this is failing to delete because the date is included as part of the string.
How can I get around this?
The date is selected by the user in a form control then set to TempVars using TempVars!tmpEndDate = Me.txtEndDate.Value
Code:
Dim strSQL As String
strSQL = "Delete * From [tblBalance] WHERE [TransactionDate] = " & CDate(TempVars!tmpStartDate)
DoCmd.RunSQL strSQL
The value of strSQL is Delete * From [tblBalance] WHERE [TransactionDate] = 4/4/2023
I believe this is failing to delete because the date is included as part of the string.
How can I get around this?