Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts

    If IsOpen avent (Access 2000)

    How can i make the Form Frm2 to be opened only in case the form Main is opened?

    In the OnOpen event of the form Frm2 i want to put the condition
    If the Form Main is opened then
    DoCmd.OpenForm "Main"

    How can i do it?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: If IsOpen avent (Access 2000)

    Your question is unclear: what does If the Form Main is opened then DoCmd.OpenForm "Main" mean?

    This is a slightly modified version of a utility function from the Northwind sample database:

    Function IsFormLoaded(ByVal strFormName As String) As Boolean
    ' Returns True if the specified form is open in Form view or Datasheet view.
    If SysCmd(acSysCmdGetObjectState, acForm, strFormName) Then
    IsFormLoaded = Forms(strFormName).CurrentView
    End If
    End Function

  3. #3
    2 Star Lounger
    Join Date
    Nov 2001
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If IsOpen avent (Access 2000)

    i beg to be apologized.Actually i wanted to open the form F2 only through the form main, and not to allow the form F2 to be opened
    by itself. Is there any simple method to do it ?Maybe to put something in the record source ?

    Best regards

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: If IsOpen avent (Access 2000)

    You can use the On Open event of F2, and set Cancel to True if Main is not loaded:

    Private Sub Form_Open(Cancel As Integer)
    If IsFormLoaded("Main") = False Then
    MsgBox "This form is not meant to be opened by itself.", vbInformation
    Cancel = True
    End If
    End Sub

    IsFormLoaded is the function I posted in my previous reply. Replace "Main" by the actual name of the main form if necessary.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •