|
-
Sep 24th, 2002, 01:08 PM
#1
Thread Starter
Member
active child form on MDi
Is there a way to tell if there is a child form active on an mdi form? I am getting an error when I try to use the activeform property when there are no active forms. Is there an easy way to check this?
-
Sep 24th, 2002, 01:09 PM
#2
Check to see if the ActiveForm property is Nothing first before using it..... I think there is also a ChildCount or a ChildFormCount, some sort of count property that returns the number of child forms for an MDI.
-
Sep 24th, 2002, 01:14 PM
#3
Thread Starter
Member
Doing this:
If frmMDI.ActiveForm = Nothing then
msgbox "nothing"
end if
ends up giving me an invalid use error. I will check the other suggestion you gave though.
-
Sep 24th, 2002, 02:33 PM
#4
Thread Starter
Member
I need to know the count of the child forms that are active not just the count. There doesn't seem any properties that are built in. Please let me know if you have other suggestions
-
Sep 24th, 2002, 03:50 PM
#5
Hyperactive Member
You can have several child open but only one of them will be active so the number of active forms will be 1.
In order to check the active form and not getting error you can use an error treatment
VB Code:
on error goto error
'check active form
exit sub
error:
MsgBox "no form active"
End Sub
-
Sep 25th, 2002, 10:11 AM
#6
Thread Starter
Member
Thanks. Is there anyway to check to see how many child forms are open?
-
Sep 25th, 2002, 10:26 AM
#7
PowerPoster
There are few different ways to do this:
1. Create a Public intNumberOfChilds As Integer at the module level and increment it on evry Child's Form_Load event.
2. Loop through Forms collection and check wheter or not frm.MDIChild = True and if YES then you would just increment some local counter.
3. Create MDIForm Public Property to a number of currently loaded childs (it will be incremented on each child's form_load)
In case 1 and 3 you will have to decrement number on each child Unload event.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|