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!

Form Properties Question 1

Status
Not open for further replies.

missymarie1014

Technical User
Mar 15, 2007
50
US
This is Access 2000. I have a problem which I have worked around, but I would like to get some advice on how to properly address this issue. I have a modal form which is called up from another form based on criteria, so sometimes it opens and sometimes it does not. It is an informational form only, no interaction from the user. A dialog box appears at the same time, whether the form is opened or not, and once the dialog box receives a yes or no response, I want the form to close as part of the ongoing procedure related to the dialog box response. There is no problem getting the form to close if it is open (I used the visible property as a criteria for the code), but in a situation where the form is not open, this code was producing an error message because it could not find the form to analyze the property. Obviously the visible property is not the way to go about this. What code technique or form property can be used to close a form if it is open, and if it is not open, do nothing without producing an error. This is a modal form. Thanks for any help!!!
 
A starting point:
If CurrentProject.AllForms("your form").IsLoaded Then DoCmd.Close acForm, "your form"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I tried to apply this property but I still receive errors when the form is not loaded. The object cannot be located. Here is the code.....
Code:
    If Response = vbNo And Forms!UnprocessedBatchNegativeShelfQuantityOnHandForm.IsLoaded = True Then
        DoCmd.Close acForm, "UnprocessedBatchNegativeShelfQuantityOnHandForm", acSaveNo
        DoCmd.Close acForm, "ProcessBatchFormWithLookup", acSaveNo
        stDocName = "ProductionMainMenuForm"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
        Exit Sub
        Else
        If Response = vbNo Then
            DoCmd.Close acForm, "ProcessBatchFormWithLookup", acSaveNo
            stDocName = "ProductionMainMenuForm"
            DoCmd.OpenForm stDocName, , , stLinkCriteria
            Exit Sub
        End If
    End If
    
If Response = vbYes And Forms!UnprocessedBatchNegativeShelfQuantityOnHandForm.IsLoaded = True Then
    DoCmd.Close acForm, "UnprocessedBatchNegativeShelfQuantityOnHandForm", acSaveNo
    rst.Close
    rs.Close
    Set rst = Nothing
    Set rs = Nothing
End If
 
Please, reread my previous answer !
replace this:
Forms!UnprocessedBatchNegativeShelfQuantityOnHandForm.IsLoaded
with this:
CurrentProject.AllForms("UnprocessedBatchNegativeShelfQuantityOnHandForm").IsLoaded

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you PHV! Works like a charm. Sorry to exasporate you so early in the day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top