Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / March 2007

Tip: Looking for answers? Try searching our database.

Opening a form already open

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Victoria - 02 Mar 2007 18:41 GMT
I have a switchboard with buttons to open other forms.  Here is an example of
On Click code...
   DoCmd.OpenForm ("frmCustomers")
   Forms.Item("frmSwitchB").Visible = False

The form so opened has a 'return to switchboard button', cmdSwitch, with
code...
   Me.Visible = False
   Forms.Item("frmSwitch").Visible = True

Everything seems to be working as expected.  But... when I click a button on
FrmSwitch, I don't really know if the form it is trying to open is already
open but just not visible.  Does it matter?  Does Opening a non-visible but
already open form just result in making it visible?  (or am I opening the
form yet again, not knowing that I'm building up a collection of invisible
copies)
Mr B - 02 Mar 2007 22:39 GMT
Here is a function that will tell you if the form is already open:

Public Function IsLoaded(ByVal strFormName As String) As Boolean
' 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

Just call the function like this:

If IsLoaded("frmYourFormName") Then
   Forms![frmYourFormName].Visible = True
Else
   DoCmd.OpenForm "frmYourFormName"
End If

Signature

HTH

Mr B

> I have a switchboard with buttons to open other forms.  Here is an example of
> On Click code...
[quoted text clipped - 12 lines]
> form yet again, not knowing that I'm building up a collection of invisible
> copies)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.