Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox "Value" possibility 2

Status
Not open for further replies.

Genotix

Programmer
Dec 16, 2004
53
NL
Hi All,

I've got a problem with a listbox and it's connection to a field in a database.

I've got al listbox that contains of the "Description" of multiple Components.
The list of descriptions is retrieved from a database Table called Component.
The primairy key of this table is a NUMBER.

In a table Recipe there's a foreign key pointing to the primary key in the table Component.

Operation :
When I click a "Description" from the listbox I want the database to alter the foreign key in the Recipe table to the
one that is coupled to the clicked "Description".

Now in HTML there is a listbox where one can add a "Post value" that differs from the clicked selection.
Is it possible to link a combobox to a recordset so that the foreign key will change on selection of a description

Linux IS userfriendly.
It's only very selective about who it's friends are.
 
Are you creating the contents of the listview from a recordset. If so try using a datalist, which has the same functionallity as a listview with a couple of extra features.

To load the datalist from a recordset that contains two fields (PK_FieldName and Description);

With DataList1
set .RowSource = Recordset
.ListField = "Description" 'This field is displayed in the datalist view
.BoundColumn = "PK_FieldName" 'Linked field to the displayed values
End With

To obtain the primary key value based on the selected item and place it in a variable strPrimaryKey, place the following code in the Click event;

If DataList1.MatchedWithList then
strPrimaryKey = DataList1.BoundText
end if
 
Use the combobox .itemdata property to store the primary key for each item in its list property. Then you can use the .listindex property to access both values.

zemp
 
Sorry I mentioned 'Combobox' by mistake, still early. However the listbox has the same property available.

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top