By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,426 Members | 3,338 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,426 IT Pros & Developers. It's quick & easy.

Checking for opened form

P: n/a
Hi

How can I check in code if a form is currently open i.e. running?

Thanks

Regards
Aug 24 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
John wrote:
Hi

How can I check in code if a form is currently open i.e. running?

Thanks

Regards

You can use SysCmd
? SysCmd(acSysCmdGetObjectState, acForm, "FormName")

0 = not open, 1 = design mode, 3 = open

Or you can enumerate the open forms like this
Function IsLoaded(strFormName)
Dim i
IsLoaded = False
For i = 0 To Forms.Count - 1
If Forms(i).FormName = strFormName Then
IsLoaded = True
Exit Function
End If
Next
End Function
Aug 24 '06 #2

P: n/a
On Thu, 24 Aug 2006 21:23:28 GMT, salad <oi*@vinegar.comwrote:
>John wrote:
>Hi

How can I check in code if a form is currently open i.e. running?

Thanks

Regards

You can use SysCmd
? SysCmd(acSysCmdGetObjectState, acForm, "FormName")

0 = not open, 1 = design mode, 3 = open

Or you can enumerate the open forms like this
Function IsLoaded(strFormName)
Dim i
IsLoaded = False
For i = 0 To Forms.Count - 1
If Forms(i).FormName = strFormName Then
IsLoaded = True
Exit Function
End If
Next
End Function

Alternatively, if you use ADO, you could use the AllForms Collection.

If CurrentProject.AllForms("frmMyForm").IsLoaded Then

-=-=-=-=-=-=-=-=-=-=-=-=
Randy Harris
tech at promail dot com
Aug 24 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.