Results 1 to 11 of 11
  1. #1
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100

    Red face Unanswered: I cannot set combox.listIndex

    I am having problems with this property.
    I've just filled the rowsource like that (Delivery is the combobox)

    Me.Delivery.RowSourceType = "Table/Query"
    Me.Delivery.ColumnCount = 2
    Me.Delivery.ColumnWidths = "0;1750"
    Me.Delivery.RowSource = "SELECT [Delivery].[DeliveryPK], [Delivery].[DeliveryCode] FROM Delivery WHERE [Delivery].[DeliveryPK] IN (SELECT [Chemical].[DeliveryPK] FROM Chemical)"

    I know this is working properly. Now I want to set this combobox to the first item like that:

    Me.Delivery.SetFocus
    Me.Delivery.ListIndex = 0

    And VB says that I am not using properly this property.
    MSDN is saying that this property "Returns or sets the index of the currently selected item in the control".

    Any idea?

    Thanks a lot.

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    What is the result of your Select? Do you have datat or it returns NULL?

  3. #3
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100
    Originally posted by hammbakka
    What is the result of your Select? Do you have datat or it returns NULL?
    Yes, it is checked, I have 2 items.

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Try the SELECTED property

    yourListBox.Selected(2) = True
    Will set the thired Item in the ListBox Selected

  5. #5
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    ListIndex is a Read Only property
    You can not change it

  6. #6
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100
    Originally posted by hammbakka
    Try the SELECTED property

    yourListBox.Selected(2) = True
    Will set the thired Item in the ListBox Selected
    It says that this property doesn't exist. By the way, is a combobox, not a listbox as you remarked

  7. #7
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713

    Re: I cannot set combox.listIndex

    Originally posted by pipeio
    I am having problems with this property.
    I've just filled the rowsource like that (Delivery is the combobox)

    Me.Delivery.RowSourceType = "Table/Query"
    Me.Delivery.ColumnCount = 2
    Me.Delivery.ColumnWidths = "0;1750"
    Me.Delivery.RowSource = "SELECT [Delivery].[DeliveryPK], [Delivery].[DeliveryCode] FROM Delivery WHERE [Delivery].[DeliveryPK] IN (SELECT [Chemical].[DeliveryPK] FROM Chemical)"

    I know this is working properly. Now I want to set this combobox to the first item like that:

    Me.Delivery.SetFocus
    Me.Delivery.ListIndex = 0

    And VB says that I am not using properly this property.
    MSDN is saying that this property "Returns or sets the index of the currently selected item in the control".

    Any idea?

    Thanks a lot.
    MyComboBox.Value= ....

    This will select the matching value for the BOUND column ...

  8. #8
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100

    Re: I cannot set combox.listIndex

    Originally posted by M Owen
    MyComboBox.Value= ....

    This will select the matching value for the BOUND column ...
    Hi Owen, but the problem ist that I cannot assign a value, since I don't know in runtime which are the items of the combobox.

  9. #9
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713

    Re: I cannot set combox.listIndex

    Originally posted by pipeio
    Hi Owen, but the problem ist that I cannot assign a value, since I don't know in runtime which are the items of the combobox.
    Ah ... OK. Do this:

    Mycombobox.Value=MyCombobox.Column(XXX,0)

    Where XXX is the Bound column ...

    P.S. - I've solved this one before ... It's in the archive somewhere ...

  10. #10
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100

    Re: I cannot set combox.listIndex

    Originally posted by M Owen
    Ah ... OK. Do this:

    Mycombobox.Value=MyCombobox.Column(XXX,0)

    Where XXX is the Bound column ...

    P.S. - I've solved this one before ... It's in the archive somewhere ...
    Thanks, I will try tomorrow, cause now it's time to go home.

    Thanks a lot. But, sorry, as I am a newbye, I don't understand what is a Bound column. I will look it in the manual tomorrow. thanks thanks thanks

    :-D

  11. #11
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100
    Quote Originally Posted by M Owen
    Ah ... OK. Do this:

    Mycombobox.Value=MyCombobox.Column(XXX,0)

    Where XXX is the Bound column ...

    P.S. - I've solved this one before ... It's in the archive somewhere ...
    Great!! It works. You are the master!!! :-D

    Thanks a lot.

Posting Permissions

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