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

How to make a form visible if given the form name 1

Status
Not open for further replies.

BitZero

Programmer
Mar 11, 2008
100
US
Hi

I have a form called frmMenuMain which has button that opens frmReport. When the button is pressed, frmReport is opened, and then I do a me.visible = false to make frmMenuMain invisible.

When the user exits frmReport, I do a docmd.close, and then have the following code:

Code:
If CodeProject.AllForms("frmMenuMain").IsLoaded Then
    Form_frmMenuMain.Visible = True
Else
    DoCmd.OpenForm "frmMenuMain"
End If

I would like to make this code into a subroutine where the form name is passed as a parameter. It would look something like this:

Code:
Public Sub FormVisible(lFormName As String)


    If CodeProject.AllForms(lFormName).IsLoaded Then
        xxxxxxxxx.Visible = True
    Else
        DoCmd.OpenForm lFormName
    End If
    
End Sub

My question is, what command do I use to make the form visible, given a string with the form name? What should the xxxxxxxx.Visible = True line look like?

Also, is there a better way to do this? If form A calls form B, I want form A to be invisible until form B is done, and then become visible again.

thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top