Open one form and close an existing form specifically?

  • Thread starter Thread starter Vince
  • Start date Start date
V

Vince

Hi,

I would like to know if it is possible to OPEN X Form,
then when the user opens Y Form close tell Access to close
the X Form? Control it specifically?

Does any one know how to do this?

Do I need code if so does anyone know it?

Thanks!

Vince
 
Using a routine included in the Northwind sample database (included with
Access, and relisted below) called IsLoaded you can determine if the form is
open:

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


Once you have placed this function (preferably in a general "utility"
module, not in your form's module so that you can use it for other forms as
well), then enter code like this in your YForm's On Open procedure:

If IsLoaded("MyXForm'sName") then
DoCmd.Close acForm, "MyXForm'sName"
End If

You can use a variable instead of text for the name of your XForm. Hope this
gets you on the right track.
 
Back
Top