I am trying to add up a list of dates that match a criteria... a search box result.
I have tried DCount, and now I'm doing it through SQL, and no matter what combinations I try I still get an error - usually 3075 - Syntax error (missing operator)
But I can't find anything missing - I copy the SQL into a query view and it works perfectly... but it won't work on its own. And I've tried using DCount with the query as a query object, and I get the same error.
I am sticking with the SQL version (as I've heard it's the most stable)... but I seriously have no idea what I'm doing wrong!?
I've used the >= And < option as it solves an issue with Date Time.
I can't seem to figure out what operator is missing!? :banghead:
I have tried DCount, and now I'm doing it through SQL, and no matter what combinations I try I still get an error - usually 3075 - Syntax error (missing operator)
But I can't find anything missing - I copy the SQL into a query view and it works perfectly... but it won't work on its own. And I've tried using DCount with the query as a query object, and I get the same error.
I am sticking with the SQL version (as I've heard it's the most stable)... but I seriously have no idea what I'm doing wrong!?
Code:
Dim ResultCount As Long
Dim DateSearch As Date
Dim MyDate As String
Dim MyDateAdd As Date
Dim varReturnValue As Variant
DateSearch = [Forms]![EnterDate]![NumberBox]
MyDateAdd = DateAdd("d", 1, DateSearch)
MyDate = "SELECT * FROM tblInvoiceQuote WHERE [Date Paid] >= #" & DateSearch & "# And <#" & MyDateAdd & "#; "
MsgBox MyDate
varReturnValue = CurrentDb.OpenRecordset(MyDate)(0)
'ResultCount = DCount("[InvoiceNumber]", )
MsgBox ResultCount
I've used the >= And < option as it solves an issue with Date Time.
I can't seem to figure out what operator is missing!? :banghead: