Is Form Open

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

Guest

In the open event of SpoilForm I have the following:
Dim Job As Integer
Job = Nz([Forms]![ProductionForm]![JobNumber])

I want to use the value from the ProductionForm if it is available. If the
ProductionForm is open I want to use the information from it to fill in the
SpoilForm JobNumber. If the ProductionForm is not open I want to bypass this
step and the information will have to be entered by the user.
How do I find out if the form is open?
Once I know if it is open can I set up a condition such as an If Then End IF.

Thank you for your help
Allan
 
This isn't the exact answer, but you can loop through the Forms collection.
I believe only OPEN forms appear in the forms collection, vs the AllForms
collection. But I am foggy on this and you should look up both.

Kurt
 
AHopper said:
In the open event of SpoilForm I have the following:
Dim Job As Integer
Job = Nz([Forms]![ProductionForm]![JobNumber])

I want to use the value from the ProductionForm if it is available.
If the ProductionForm is open I want to use the information from it
to fill in the SpoilForm JobNumber. If the ProductionForm is not
open I want to bypass this step and the information will have to be
entered by the user.
How do I find out if the form is open?
Once I know if it is open can I set up a condition such as an If
Then End IF.

Thank you for your help
Allan

If you're using Access 2000 or later, you can use code like this:

If CurrentProject.AllForms("ProductionForm").IsLoaded Then
Job = Nz([Forms]![ProductionForm]![JobNumber])
Else
' do something else?
End If

If you're using Access 97, there's a user-defined function called
IsLoaded() in the sample databases (Northwind and Solutions) that you
can call to find out.
 
Allan
You can try:
If (SysCmd(acSysCmdGetObjectState, acForm, "ProductionForm") And
acObjStateOpen) <> True Then 'form is open
'fill in the SpoilForm JobNumber
Else 'form is closed
' use inputbox function
End If

Cheers
Krock
 
Back
Top