PDA

View Full Version : [SOLVED:] Run-time error in code



sdhruv
06-08-2015, 08:25 PM
hi I am running this code:
Private Sub Command6_Click()
x = 0
y = ElecMLFB
Do While x < 6
Do
y = DateAdd("d", 1, y)
Loop Until DCount("*", "tblHolidays", "Holidaydate = " & Format$(y, "\#mm\/dd\/yyyy\#")) = 0

x = x + 1
Loop
sixd = y
End Sub

But, I am getting a 'Run-time error 3075'
syntax error (missing operator) in query expression "Holidaydate = "

I have obviously checked if the field names are the same, and the field is the primary key, I have also used this code in multiple other access programs and it worked perfectly then, this error has suddenly come up, I have tried to change the quotation marks but I know single quotes are only used for text.
The statement in red is the problem statement.(It isn't red in the code, I just did it to highlight the statement in question here)
Please Help.

jonh
06-09-2015, 01:21 AM
I can only replicate that error by commenting out the Format$


Private Sub Command3_Click()
x = 0
y = Date 'ElecMLFB
Do While x < 6
Do
y = DateAdd("d", 1, y)
s = "Holidaydate = " '& Format$(y, "\#mm\/dd\/yyyy\#")
Debug.Print s
w = DCount("*", "tblHolidays", s)
Loop Until w = 0
x = x + 1
Loop
sixd = y
End Sub

sdhruv
06-09-2015, 02:48 AM
Yeah its pretty stupid, it works on the other programs I made so I just made a copy of those programs and did it. Thanks though.