how do i check if a form is open ? (1 Viewer)

Gr3g0ry

Registered User.
Local time
Today, 01:12
Joined
Oct 12, 2017
Messages
163
i have a report that is called from one of two forms, this causes the criteria prompts from the unopened form to be displayed . i need to check which form is open and set parameters to solve my issue.

how do i check/determine which form is open ??
 
Last edited:

MarkK

bit cruncher
Local time
Today, 01:12
Joined
Mar 17, 2004
Messages
8,181
You can use CurrentProject.IsLoaded to find a stand-alone form. Or do you need to know if the form is open as a subform? That is possible too, but harder.
Cheers,
Mark
 

Gr3g0ry

Registered User.
Local time
Today, 01:12
Joined
Oct 12, 2017
Messages
163
thanks. so id say
if CurrentProject.IsLoaded = frmAddnewCustomer Then
blah blah blah ??

frmAddnewCustomer is the name of a form
 

MarkK

bit cruncher
Local time
Today, 01:12
Joined
Mar 17, 2004
Messages
8,181
No. Sorry, my instructions were incomplete, you use the AllForms collection of the CurrentProject object, more like...
Code:
If CurrentProject.AllForms(FormName).IsLoaded Then
[COLOR="Green"]  'this block will execute if the form FormName is open [/COLOR]
End If
Because that is a little verbose, I sometimes write a function...
Code:
Function IsLoaded(FormName as String) as Boolean
   IsLoaded = CurrentProject.AllForms(FormName).IsLoaded
End Function
Which tidies up the previous If...End If expression to...
Code:
If IsLoaded(FormName) then 
[COLOR="green"]   'this block will execute if the ...[/COLOR]
End If
hope that's clearer...
Mark
 

Gr3g0ry

Registered User.
Local time
Today, 01:12
Joined
Oct 12, 2017
Messages
163
a bit clearer. if i encounter any more issues, ill return. thanks man
 

Users who are viewing this thread

Top Bottom