Results 1 to 7 of 7

Thread: Child Form thing

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    Barrie, Ontario - Canada
    Posts
    85

    Child Form thing

    Hi Folks,
    I have several forms as part of a project. When I began this project, I didn’t know any better, but now I’ve discovered the application needs to be MDI capable.
    Essentially, several of the data entry parts of most forms need to be handled a bit differently to validate the entry. A Message Box or Input Box would not be sufficient so I have had to make a small specific form that would be a child to all the others.
    Trouble is: I have made no provision anywhere in the code to allow one form to be a child of another… perhaps better said “no provision for any of the forms to be child aware”.
    In any event, I use this code: frmCustCmb.Show vbModal, Me to call up that little verification form but receive an error
    No MDI form available to load (Error 366)

    and I know that frmCustCmb.MDIchile=True

    So I have a couple of questions about this “child form” stuff:
    (1) How do I tell the parent form, in this case frmCustomer that it is a parent, and should let the child work?
    (2) The start-up object for this application is a sub Main(). What ought I do to convert the whole thing to an MDI capable app?

    Many thanks
    -Paul-

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Child Form thing

    You need to add an MDI Parent Form to your project (Project -> Add MDI Form menu item). A project can have only one MDI form. All other forms whose MDIChild property is set to True will automatically be "contained" within the MDI Form. There are some things you should be aware of when switching to an MDI Form.

    Child Forms cannot be shown modally.
    Menus on Child forms replace the menu on the MDI Form (when the child becomes active).
    The Child form's Height and Width properties, as set at design time, are ignored in an MDI application.

    There will be more...

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    Barrie, Ontario - Canada
    Posts
    85

    Re: Child Form thing

    Yeeeech!
    I didn't know it would be complicated like this.

    Is there another way that I can use a "form" as a fancier input box? I do need to limit the data entry to tw0 characters.

    Thanks Paul

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Child Form thing

    This code (with MDIChild = False)

    frmCustCmb.Show vbModal, Me

    basically does create a parent/child relation. Since the form is Modal, it must be closed before any other Form can become active. Since you specified Me for the second argument (Owner), "Me" is its Parent form.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    Barrie, Ontario - Canada
    Posts
    85

    Re: Child Form thing

    Thanks brucevde,

    It works like a charm. One question I hadn't thought about when I began this would be how to "exit" that wee form and return to the parent?

    How do I do that?

    Thanks
    -Paul-

  6. #6
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Child Form thing

    Typically, a modal form has an Ok or Cancel button (or whatever name is appropriate for your app). In the Click event of these buttons execute

    Unload Me
    or
    Me.Hide

  7. #7

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