Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Test for open query so I may requery as combo box changes

Status
Not open for further replies.

Poduska

Technical User
Dec 3, 2002
108
US
How do I test to see if a query is open so I may requery it as the combo boxes in my form are updated. I use a simple command button to open the query when the user has selected the approporiate criteria. If the query is already open then either close and reopen the query or requery. No fancy forms for the output as the user is just going to cut and paste data into Excel anyway.

I can open the query fine but when I change the criteria on the form the query does not update. I am using just the default output from the command button wizard.

Code:
Private Sub cmd_run_store_inv_qry_Click()
On Error GoTo Err_cmd_run_store_inv_qry_Click

    Dim stDocName As String

    stDocName = "qry_store_inventory_from_form"
    DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_cmd_run_store_inv_qry_Click:
    Exit Sub

Err_cmd_run_store_inv_qry_Click:
    MsgBox Err.Description
    Resume Exit_cmd_run_store_inv_qry_Click
    
End Sub
I must be doing this in a wierd way as I found almost nothing by searching.

Thanks.
 
It is more usual to use a form. This should suit:

Code:
Function IsLoaded(ByVal strQueryName As String) As Boolean
    
    Const conObjStateClosed = 0
    Const conDesignView = 0
    
    If SysCmd(acSysCmdGetObjectState, acQuery, strQueryName) <> conObjStateClosed Then
        IsLoaded = True
    End If
    
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top