Update Combo Box from List Box (1 Viewer)

Len Boorman

Back in gainfull employme
Local time
Today, 06:28
Joined
Mar 23, 2000
Messages
1,930
I have a form based upon a table that is opened in Add mode. On the form is a List box in addition to the fields from the table.

The purpose of the list box is to show existing data. Initially the list box is not visible but selection of a Part Reference from a combo box (tab index 0) requeries the list box and makes it visible.

A number of the entries to be made are selections from combo boxes that have as their source various control tables.

What I want to do is to click on an existing data record for the Part within the list box and update a combo box on the form with the value within the bound column of the list box for the list box row selected

Ideas please

Len B
 

FoFa

Registered User.
Local time
Today, 00:28
Joined
Jan 29, 2003
Messages
3,672
Been awhile since I have done this, so someone else may have to chime in and correct me, but off the top of my head I can't just remember if you need to put the value in the combobox VALUE property, or roll through the combobox items until a match is found and set the appropiate index value. I am assuming you are trying to set it to an existing value in the combobox?
Anyone?
 

Len Boorman

Back in gainfull employme
Local time
Today, 06:28
Joined
Mar 23, 2000
Messages
1,930
Your assumption correct. Thanks for hint. I will investigate further.

More comments welcome.

Len B
 

Len Boorman

Back in gainfull employme
Local time
Today, 06:28
Joined
Mar 23, 2000
Messages
1,930
Been investigating the Value property. I have at the moment got as far as the code below as the onclick event on a line within the list box

[cbo_Function]![F_Id].Value = [List35]![F_Id].Value

cbo_Function is the name of the combo box I want to update. F_Id is the bound column of the combo box.
List 35 is the name of the list box with again F_Id being the bound column of the list box.

The source of the combo box is from a table where F_Id is an autonumber. The source of the list box is a table of existing records where F_Id is a long integer.

Basically I am getting a type mismatch error when I click on the line in the list box.

Have tried various combination of the above but this appears to be the closest but it still does not work.

Anybody any ideas ?

Thanks

Len B
 

Len Boorman

Back in gainfull employme
Local time
Today, 06:28
Joined
Mar 23, 2000
Messages
1,930
Just when you think that you have tried everything you try again and it works.

For those wondering what the answer is

[cbo_Function].Value = [List35].Value

Just make sure the bound columns are set correctly and that multi select on the list box is None

Len B
 

Len Boorman

Back in gainfull employme
Local time
Today, 06:28
Joined
Mar 23, 2000
Messages
1,930
Now trying to extend solution above.

In order to do this I need to change the bound column. Again no joy at the moment. I have my suspicions that perhaps you cannot change the bound column on the fly.

Have tried
ListBox.BoundColumn= 3

but if the bound column is say 4 then it remains at 4

Hints and tips welcome

Len B
 

Len Boorman

Back in gainfull employme
Local time
Today, 06:28
Joined
Mar 23, 2000
Messages
1,930
The thing about this forum is that it is so thought provoking.

Searched on a few associated subjects and realised there was also a column reference available.

So can update one combo box using the value in bound column and update a second by using the value in a specific column. Magic.

Remember that column refs start from 0

(Decided to put solution here as it may be of interest to somebody else and perhaps iy will save them several hours brain ache)

Len B
 

directormac

Occasional Presence
Local time
Today, 06:28
Joined
Oct 24, 2001
Messages
259
Len Boorman said:
The thing about this forum is that it is so thought provoking.

<SNIP>

(Decided to put solution here as it may be of interest to somebody else and perhaps iy will save them several hours brain ache)


Len: THANK YOU for that. The other great thing about this forum is the fact that people DO go back and post their solutions, so that others searching later can find them. Kudos.

--Grateful Mac
 

Users who are viewing this thread

Top Bottom