Results 1 to 5 of 5

Thread: Childform that has focus

  1. #1

    Thread Starter
    Frenzied Member aikidokid's Avatar
    Join Date
    Aug 2002
    Location
    Bristol, UK
    Posts
    1,968

    Childform that has focus

    How can I write the following with the correct name of the childform that is open.
    VB Code:
    1. If "Open Childform Name" = cForm1 then ...
    If somebody helps you, take time to RATE the post. I do.

    "FAILURE IS NOT AN OPTION. It comes bundled with the software."

    Below are some of the threads that have helped me along the way:

    CodeBank submission:
    Listview Backcolor (without subclassing)

    Loading Treeview Nodes From A Database, Creating Registry Keys, Count Number of Lines in TextBox , Excellent RichTextBox Tricks & Tips
    Ideas & Screen Shots For A Code Library App
    How to do Data validation in Excel, Conditional Formating in Excel

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    Use the MDIForm's ActiveForm Property, i.e.
    VB Code:
    1. If MDIForm1.ActiveForm.Name = "Form1" Then
    2.   ...
    3. End If

  3. #3

    Thread Starter
    Frenzied Member aikidokid's Avatar
    Join Date
    Aug 2002
    Location
    Bristol, UK
    Posts
    1,968
    Thanks Aaron,
    I am now getting the error
    Object variable or with block variable not set.
    This is my line of code
    VB Code:
    1. If MDIMain.ActiveForm.Name = "frmGradingCalc" Then cmbCourseList.Text = NewDate
    Where NewDate is a global variable.
    If somebody helps you, take time to RATE the post. I do.

    "FAILURE IS NOT AN OPTION. It comes bundled with the software."

    Below are some of the threads that have helped me along the way:

    CodeBank submission:
    Listview Backcolor (without subclassing)

    Loading Treeview Nodes From A Database, Creating Registry Keys, Count Number of Lines in TextBox , Excellent RichTextBox Tricks & Tips
    Ideas & Screen Shots For A Code Library App
    How to do Data validation in Excel, Conditional Formating in Excel

  4. #4
    Frenzied Member John McKernan's Avatar
    Join Date
    Jan 2002
    Location
    SE PA
    Posts
    1,295
    Originally posted by aikidokid
    Thanks Aaron,
    I am now getting the error
    Object variable or with block variable not set.
    This is my line of code
    VB Code:
    1. If MDIMain.ActiveForm.Name = "frmGradingCalc" Then cmbCourseList.Text = NewDate
    Where NewDate is a global variable.
    Where have you placed this line of code?

  5. #5
    Fanatic Member Armbruster's Avatar
    Join Date
    Sep 2002
    Location
    Maryland Heights, MO
    Posts
    857
    You will get this error if there are no active child forms, i.e. the form does not exist (object variable not set)

    Try this . . .
    VB Code:
    1. If MDIMain.ActiveForm Is Nothing Then
    2.     'no child form loaded
    3.     'put whatever code you need here
    4. ElseIf MDIMain.ActiveForm.Name = "frmGradingCalc" Then
    5.     cmbCourseList.Text = NewDate
    6. End If
    "Look! Up in the sky! It's a bird! It's a plane! It's Diaper-Head Boy! (there by my name!) Yes, Diaper-Head Boy, who disguised as my son, Seth, fights a never-ending battle for truth, justice and terrorizing my house!

    Resistance is futile, you will be compiled . . . Please!

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