Hiding/unhiding forms

F

FatMax

Access 97. I have two forms A and B which both contain a command
button that opens form C and hides A or B.

When I close C I'd like to return to A or B (whichever one I opened C
from).

I'd appreciate some clues :)

FatMax
 
A

Allen Browne

Place a text box on form C to hold the name of the form that opened it:

DoCmd.OpenForm "C"
Forms!C!txtCallingForm = Me.Name
Me.Visible = False


Then in the Close event of form C:

If Not IsNull(Me.txtCallingForm) Then
Forms(Me.txtCallingForm).Visible = True
End If
 
R

Reggie

FatMax, I'm assuming you have both forms open and that whichever form you
open formC from that you are hidding that form. After that, when you close
formC you want the one you hid to be shown.


Private Sub Form_Close()
On Error GoTo Err_Close

If IsLoaded("FormA") And Not Forms!FormA.Visible Then
Forms!FormA.Visible = True
Forms!FormA.SetFocus
ElseIf IsLoaded("FormB") And Not Forms!FormB.Visible Then
Forms!FormB.Visible = True
Forms!FormB.SetFocus
End If

Exit_Close:
Exit Sub

Err_Close:
MsgBox Err.Description & Err.Number
Resume Exit_Close
End Sub
***********************
Public Function IsLoaded(ByVal strFormName As String) As Integer
Const CLOSED = 0
Const DESIGN = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> CLOSED Then
IsLoaded = True
End If
End Function
 
F

FatMax

Thanks for the advice. I only have A or B open at any one time so I
went with the idea from Allen Browne which worked a treat.

Mucho regards to both of you
FatMax
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top