Question : Run multiple paramenter query from one button

I have several parameter queries (append and delete) that are based on a date range between start and end date on one of my forms. I thought I could use the following code to run the multiple queries at once and also I wont have to see the warning messages, but I'm getting an error message in VBA. Is there a way to run multiple parameter queries at once without getting the warning messages?
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
With CurrentDb
.execute "query1"
end with
with CurrentDb
.exectue "query2"
end with
etc.....

Answer : Run multiple paramenter query from one button

"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
Random Solutions  
 
programming4us programming4us