"Is there a way to pass the parameters I have in the Main Form to VB and then execute the queries? "
Yes.
1) Put this code in a standard VBA module - do not name the module the same as the Function:
Public Function RPT_ListDateRngSetGet(sOp As String, Optional vVal As Variant)
'ExtName:Report Set Get Date Range
'Actions:Sets or Get various date range values related to reports
'Ex Call:RPT_ListDateRngSetGet
("SetDateRngFrom",
)
' From query WHERE clause: RPT_ListDateRngSetGet ("GetDateRngFrom")
'---------------------------------------------------------
Static vTpDateRngFrom, vTpDateRngTo
Select Case sOp
Case "SetDateRngFrom": vTpDateRngFrom = vVal
Case "GetDateRngFrom": RPT_ListDateRngSetGet = vTpDateRngFrom
Case "SetDateRngTo": vTpDateRngTo = vVal
Case "GetDateRngTo": RPT_ListDateRngSetGet = vTpDateRngTo
End Select
End Function
2) Put this code in Date From text box's AfterUpdate (same for Date To):
Call RPT_ListDateRngSetGet("SetDateRngFrom", Me.txtDateFrom)
3) Change your where clause that gRay suggested to:
WHERE [YourDateFieldName} BETWEEN RPT_ListDateRngSetGet("GetDateRngFrom") AND RPT_ListDateRngSetGet("GetDateRngTo")
4) Use the code gRay suggest @ http:#a26084001 ... modified like so:
With CurrentDb
.Execute "query1", dbFailOnError
.Execute "query2", dbFailOnError
'etc....
End With
mx