Results 1 to 7 of 7

Thread: active child form on MDi

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2002
    Location
    NY
    Posts
    60

    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?

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    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.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2002
    Location
    NY
    Posts
    60
    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.

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2002
    Location
    NY
    Posts
    60
    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

  5. #5
    Hyperactive Member
    Join Date
    Nov 2001
    Location
    Catalonia
    Posts
    397
    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:
    1. on error goto error
    2. 'check active form
    3. exit sub
    4. error:
    5. MsgBox "no form active"
    6. End Sub
    Josep Mª

  6. #6

    Thread Starter
    Member
    Join Date
    Jun 2002
    Location
    NY
    Posts
    60
    Thanks. Is there anyway to check to see how many child forms are open?

  7. #7
    PowerPoster
    Join Date
    Aug 2002
    Location
    NY, NY
    Posts
    2,139
    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.
    Roy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width