p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Access (http://p2p.wrox.com/forumdisplay.php?f=18)
-   -   How do I Unhide a Form? (http://p2p.wrox.com/showthread.php?t=346)

shepston June 9th, 2003 05:44 PM

How do I Unhide a Form?
 
I am using two different forms to open a third form. For simplicity, lets say FormA and FormB have buttons to open FormC.

Here is the problem. When I open FormC from either FormA or FormB, the first Form is hidden:

    [code from FormA]
    DoCmd.OpenForm "FormC", acNormal, , "Key=Forms!FormA.Key"
    Forms!FormA.Visible = False
and
    [code from FormB]
    DoCmd.OpenForm "FormC", acNormal, , "Key=Forms!FormB.Key"
    Forms!FormB.Visible = False

That part is simple enough but the problem comes when I close FormC. How do I unhide the appropriate form?

When I use the following code, I get error if FormC was opened from FormB:

    Forms!FormA.Visible = True

Any help would be appreciated.

SerranoG June 10th, 2003 06:55 AM

Quote:

quote:Originally posted by shepston
When I use the following code, I get error if FormC was opened from FormB:

    Forms!FormA.Visible = True

How about not explicitly hiding FormA or FormB? If you open FormC and maximize it, there is no need to hide the calling form. It'll be hidden behind FormC anyway. And when you close FormC, the calling form will be right there. No need to unhide it.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division

shepston June 10th, 2003 11:02 AM

That is a good idea but because of layout issues, it cannot be maximized.



***EDIT***
I was able to stretch and resize this form to cover the other form but it does not look clean since the form is only has a few lines. This puts the footer of the form on the bottom of the screen.

I would still like to find a way to unhide the other forms.

SerranoG June 10th, 2003 11:46 AM

Quote:

quote:Originally posted by shepston
 That is a good idea but because of layout issues, it cannot be maximized.
 Ah, then consider one of these two options.

1) FormC is a small form. Why not set its modal property and Pop-Up properties to YES. Set its border style to DIALOG. You would not hide the calling form, it would still be visible but it will be behind FormC. Because of the three latter settings I mentioned, users will not be able to click outside of FormC until they fill it out and click OK or CANCEL. In this way, FormC is a pop-up box people fill out. No need to hide the calling form.

2) If you STILL want to hide the calling form, on the button that opens FormC, set a global variable in the OnClick event. For example gstrCallerForm = "FormA" (or "FormB"). Then in FormC when it gets closed, the last item on FormC's OnClose Event will be
Code:

   If gstrCallerForm = "FormA" Then
      Forms.FormA.Visible = True
   Else
      Forms.FormB.Visible = True
   End If

Given the size and purpose of FormC, my preference would be option 1. Option 2 would leave a lot of "naked" space around FormC that I would not like. Especially if that naked space exposes the tables, queries, or whatever happens to be under both Forms A and C (or B and C).

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division

papparuff June 10th, 2003 11:57 AM

Add the following code to a new module. This procedure provides you a means of determining if a form is open.

Public Function IsLoaded(strFormName As String) As Boolean
' Returns True if the specified form is open in Form view or Datasheet view. ' Comments : Determines if the named form is open ' Parameters: strFormName - form to check for
' Returns : True - form is open, False - form is not open
 '
    IsLoaded = (SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> 0)

End Function

On the button on FormC that closes FormC and opens FormA or FormB add the following.

    If IsLoaded("FormA") Then
        DoCmd.OpenForm "FormA"
    ElseIf IsLoaded("FormB") Then
        DoCmd.OpenForm "FormB"
    End If

    DoCmd.Close acForm, "FormC"


John Ruff - The Eternal Optimist :-)

shepston June 10th, 2003 01:26 PM

Solution 2 from Greg and John's solution work just as I need. Thanks for giving me 2 to chose from!

Thanks for you help guys.


-Shay Shepston


All times are GMT -4. The time now is 10:18 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.