if form is open then

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

when i close a form without the previous form still open it brings up an
error and asks the user to debug is there an if statement that when the user
closes the original form that checks to see if the secondary form is still
open and closes it down

pseudo

if extra = open then
close Extra form
else
close main

any help would be great
 
Rivers,

I have a function that returns a boolean value if a form is loaded. It
looks something like:

Public Function Isloaded(FormName As String) As Boolean

Dim intLoop As Integer

Isloaded = False

If Forms.Count = 0 Then
Exit Function
Else
For intLoop = 0 To Forms.Count - 1

If Forms.Item(intLoop).Name = FormName Then
Isloaded = True
Exit Function
End If
Next
End If

End Function

To use this in your code, you would do something like:

If isloaded("Extra") then
docmd.close acform, "Extra"
Else
docmd.close acform, "Main"
Endif

HTH
Dale
 
heres the code it aint beutiful its a bit of a hack job
If IsLoaded([HelpDesk_00Start Query]) Then
Forms![HelpDesk_00Start Query].ExtrainfoButt.Visible = True
Forms![HelpDesk_00Start Query].ExtraInfoID = Forms![HelpDesk_02Extra
Information].ExtraInfoID
DoCmd.Close
Else
DoCmd.Close
End If
this code is on another form called extrainf in a close button
 
when i close a form without the previous form still open it brings up an
error and asks the user to debug is there an if statement that when the user
closes the original form that checks to see if the secondary form is still
open and closes it down

pseudo

if extra = open then
close Extra form
else
close main

any help would be great

What version of Access?
Access 2000 or newer?

If Not CurrentProject.AllForms("FormA").IsLoaded Then
Do something here
Else
Do something else
End If

In Access 97, copy this function (from the Northwind.mdb sample
database) into a module:

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

Then code some event:
If Not IsLoaded("FormA") Then
Do this
Else
Do that
End if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top