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

Open and Close a Form from Another Form

Status
Not open for further replies.

Kevsim

Instructor
Apr 18, 2000
385
AU
I have tried a few combinations without any success.
I am using FORM A and DOUBLE click an option buton to open FORM B, this works OK. When I finish with FORM B I return to FORM A. At this point I want to SINGLE click the same option button on FORM A to close FORM B.
I would appreciate any advise.
 
Add this function first - it's copied from the Northwind DB:

Function IsLoaded(strFrmName As String) As Boolean

' Determines if a form is loaded.

Const conFormDesign = 0
Dim intX As Integer

IsLoaded = False
For intX = 0 To Forms.count - 1
If Forms(intX).FormName = strFrmName Then
If Forms(intX).CurrentView <> conFormDesign Then
IsLoaded = True
Exit Function ' Quit function once form has been found.
End If
End If
Next

End Function

now, try the following on the OnClick event of your button:

private sub yourbutton_OnClick

if isloaded(&quot;FORM B&quot;) then
docmd.close acform, &quot;FORM B&quot;
else
' do nothing
end if
end sub

I think this will work for you - but in all reality, when going back to form a, why not just close form b? then you have no hassles...

Greg


 
Greg is right. Just close form B. Why be obtuse?

Rollie E (;-))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top