okay, thanks. I have swapped the parameters inside the dateadd() funtion, which still works (did work previously, too) with a manual query execution. Still gives the same error in VBA when query is executed.
Can you please spell out how to define these variables, and where, and then how to refer to them in my query? I have been reading some resources, but it is hard to decipher how to apply to my situation.
Not sure if I need to define the vars as they are entered into the form (would also double-up and define when form is loaded, in case that dates are already stored there and don't need to be altered) or just on a module that runs at some point?
Thanks again,
EDIT Updates:
I am erasing a comment about an error code that was caused by something else. I was using ,dbfailonerror even though it was a docmd.openquery command... the below appears to work!!
Code:
Option Compare Database
Public Function StartDate() As Date
StartDate = [Forms]![frm_Process]![Report Start Date]
End Function
Public Function EndDate() As Date
EndDate = [Forms]![frm_Process]![Report End Date]
End Function
Public Function EndDatePlus() As Date
EndDatePlus = DateAdd("d", 2, [Forms]![frm_Process]![Report End Date])
End Function
Sequel related to query being called...
Code:
INSERT INTO tbl_InvoicedBy_DateRange ( InvoiceId, [CreatedOn (Raw)], [Created By] )SELECT dbo_Invoice.InvoiceId, dbo_Invoice.CreatedOn AS [CreatedOn (Raw)], dbo_Invoice.CreatedByName AS [Created By]
FROM dbo_Invoice
WHERE (((dbo_Invoice.CreatedOn) Between StartDate() And EndDatePlus()));