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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

controlling how users close forms 1

Status
Not open for further replies.

techsupport3977

Technical User
Mar 7, 2005
56
US
If I have two forms that pop up. One will float on top the other. If the user closes the form below it will cause an error. Without turning the 'close' feature on the form off, how can I make it so the user will have to close the top form first before closing the bottom form?
 
use the isloaded function to see if the form is open. Northwind database has samples of this to ensure it is open just reverse the logic

Code:
Function IsLoaded(ByVal strFormName As String) As Integer
 ' Returns True if the specified form is open in Form view or Datasheet view.
    
    Const conObjStateClosed = 0
    Const conDesignView = 0
    
    If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
        If Forms(strFormName).CurrentView <> conDesignView Then
            IsLoaded = True
        End If
    End If
    
End Function
 
I do not have the northwind Db. Your code is a little advanced for me. Can you break it down in layman's terms and where should I place this function?
 
the isloaded() function should be placed in a module. From there just pass the formname to see if it is open

in the froms on unload event you would check to see if it is open if it is cancel the event

Private Sub Form_Unload(Cancel As Integer)
Cancel = isLoaded("top form name")
End Sub

if you create a database using the createdatabase wizard then you will see this in several of the examples.
 
Hi!

Just open the form in dialog mode. If you are using VB then:

DoCmd.OpenForm "YourForm", , , , , acDialog

Now the user will need to close the second form before they can do anything else.

If you are using a macro then change the Window Mode to Dialog.

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top