+ Reply to Thread
Results 1 to 4 of 4

How to make a ComboBox dependent on another?

  1. #1
    Robert.Cordani@us.schneider-electric.com
    Guest

    How to make a ComboBox dependent on another?

    I am trying to set a ComboBox to list values dependent, on what was
    selected on an earlier ComboBox.

    Private Sub ComboBox2_Change()
    Select Case Comboxbox1.ListIndex
    Case 0 'Operator Interface
    ComboBox2.AddItem "Pushbutton" 'ListIndex = 0
    ComboBox2.AddItem "Selector Switch" 'ListIndex = 1
    ComboBox2.AddItem "Cam Switch" 'ListIndex = 2
    ComboBox2.AddItem "Foot Switch" 'ListIndex = 3
    End Select
    End Sub

    But it doesn't seem to be happy with my approach, I get Run-Time error
    '424': Object Required.

    Am I missing something simple, or is this approach incorrect, is there
    another way?

    TIA


  2. #2
    Tom Ogilvy
    Guest

    RE: How to make a ComboBox dependent on another?

    I would use the click event, but as far as the error - that usually indicates
    an invalid object

    since "Comboxbox1" appears to be misspelled I would look there first.

    --
    Regards,
    Tom Ogilvy


    "Robert.Cordani@us.schneider-electric.com" wrote:

    > I am trying to set a ComboBox to list values dependent, on what was
    > selected on an earlier ComboBox.
    >
    > Private Sub ComboBox2_Change()
    > Select Case Comboxbox1.ListIndex
    > Case 0 'Operator Interface
    > ComboBox2.AddItem "Pushbutton" 'ListIndex = 0
    > ComboBox2.AddItem "Selector Switch" 'ListIndex = 1
    > ComboBox2.AddItem "Cam Switch" 'ListIndex = 2
    > ComboBox2.AddItem "Foot Switch" 'ListIndex = 3
    > End Select
    > End Sub
    >
    > But it doesn't seem to be happy with my approach, I get Run-Time error
    > '424': Object Required.
    >
    > Am I missing something simple, or is this approach incorrect, is there
    > another way?
    >
    > TIA
    >
    >


  3. #3
    Die_Another_Day
    Guest

    Re: How to make a ComboBox dependent on another?

    Quote "since "Comboxbox1" appears to be misspelled" This is a good
    reason to require "Variable Declaration". In the VB editor goto
    Tools... Options... and check "Require Variable Declaration". This
    places "Option Explicit" at the top of every new code page, requiring
    that you dim variables otherwise you will receive a compile error.
    Basically it's a spell checking service for me.

    Charles
    xl Geek
    Tom Ogilvy wrote:
    > I would use the click event, but as far as the error - that usually indicates
    > an invalid object
    >
    > since "Comboxbox1" appears to be misspelled I would look there first.
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Robert.Cordani@us.schneider-electric.com" wrote:
    >
    > > I am trying to set a ComboBox to list values dependent, on what was
    > > selected on an earlier ComboBox.
    > >
    > > Private Sub ComboBox2_Change()
    > > Select Case Comboxbox1.ListIndex
    > > Case 0 'Operator Interface
    > > ComboBox2.AddItem "Pushbutton" 'ListIndex = 0
    > > ComboBox2.AddItem "Selector Switch" 'ListIndex = 1
    > > ComboBox2.AddItem "Cam Switch" 'ListIndex = 2
    > > ComboBox2.AddItem "Foot Switch" 'ListIndex = 3
    > > End Select
    > > End Sub
    > >
    > > But it doesn't seem to be happy with my approach, I get Run-Time error
    > > '424': Object Required.
    > >
    > > Am I missing something simple, or is this approach incorrect, is there
    > > another way?
    > >
    > > TIA
    > >
    > >



  4. #4
    Robert.Cordani@us.schneider-electric.com
    Guest

    Re: How to make a ComboBox dependent on another?

    Thanks all, thats all it was, works fine now. I wonder how long I
    would have slaved over this, when the whole time it was just a
    mispelling.

    Die_Another_Day wrote:
    > Quote "since "Comboxbox1" appears to be misspelled" This is a good
    > reason to require "Variable Declaration". In the VB editor goto
    > Tools... Options... and check "Require Variable Declaration". This
    > places "Option Explicit" at the top of every new code page, requiring
    > that you dim variables otherwise you will receive a compile error.
    > Basically it's a spell checking service for me.
    >
    > Charles
    > xl Geek
    > Tom Ogilvy wrote:
    > > I would use the click event, but as far as the error - that usually indicates
    > > an invalid object
    > >
    > > since "Comboxbox1" appears to be misspelled I would look there first.
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > >
    > > "Robert.Cordani@us.schneider-electric.com" wrote:
    > >
    > > > I am trying to set a ComboBox to list values dependent, on what was
    > > > selected on an earlier ComboBox.
    > > >
    > > > Private Sub ComboBox2_Change()
    > > > Select Case Comboxbox1.ListIndex
    > > > Case 0 'Operator Interface
    > > > ComboBox2.AddItem "Pushbutton" 'ListIndex = 0
    > > > ComboBox2.AddItem "Selector Switch" 'ListIndex = 1
    > > > ComboBox2.AddItem "Cam Switch" 'ListIndex = 2
    > > > ComboBox2.AddItem "Foot Switch" 'ListIndex = 3
    > > > End Select
    > > > End Sub
    > > >
    > > > But it doesn't seem to be happy with my approach, I get Run-Time error
    > > > '424': Object Required.
    > > >
    > > > Am I missing something simple, or is this approach incorrect, is there
    > > > another way?
    > > >
    > > > TIA
    > > >
    > > >



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1