View Single Post
  #5 (permalink)  
Old June 10th, 2003, 11:57 AM
papparuff papparuff is offline
Registered User
Join Date: Jun 2003
Location: Lakewood, WA, USA.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts

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 :-)