Syntax Error while defining Date Variable

Firasath

Board Regular
Joined
Feb 20, 2011
Messages
134
Office Version
  1. 365
Hi,

I am picking up a date from the form in VBA Code and trying to execute SQL Statement. I am getting "Run Time Error "3075". Syntax Error (missing operator) in query expression". Please find below the respective Code.

Code:
Private Sub btnDeldt_Click()

Dim dt As Date

dt = Me.txtDelDt

Dim sql As String
sql = " Delete tblCompDB.ActualClosedDate WHERE (((tblCompDB.ActualClosedDate)>= #" & dt & "# "
DoCmd.RunSQL sql

sql = " Update tblCompDB.ComplaintStatus = 'Pending' WHERE (((tblCompDB.ActualClosedDate)>= #" & dt & "# "
DoCmd.RunSQL sql

End Sub

Kindly suggest.
 
Thanks James. It is not even giving error when I compile the database. I tried every possible thing except the one you suggested. Tomorrow I'll try and update you back.
 
Upvote 0

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
If your table contains time values other than 00:00:00, I would also check that any records you expect to be updated for a given date with a time value greater than this are being affected as you expect. I think you will find that the >= operation on dates with time will not null anything on the ending date where the time is greater. For example, I would not expect 05/15/2015 10:00:00 P.M. to be affected if the operation is >= 05/15/2015 and you are not using the time as well, as you indicated in your earlier post about the form control. The >= operation on dates with time is a special case.
 
Upvote 0

Forum statistics

Threads
1,215,079
Messages
6,123,005
Members
449,092
Latest member
masterms

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top