Passing a value from listbox to textbox when listbox has 2 values :( ?

VBKid04
04-13-2004, 11:05 PM
I have a listbox, that I want to pass a .text value from to a textbox.
Problem is, The listbox is holding two values (as passed by 2 fields from a recordset) like this...


For i = 0 To rstCust.RecordCount - 1

lstCust.AddItem rstCust.Fields(0).Value & " " & rstCust.Fields(1).Value
rstCust.MoveNext

Next


Which displays the list like this:

001 Smith
002 Jones
003 Black

etc.


When I click on the listbox, I want the value I click on to go to a textbox called txtCustID, but I dont want to send both values to it.

I only want to send the rstCust.Fields(0).Value to the textbox (which would be 001, 002, 003 etc. but not the name).


Can anyone help me do this?

Thanks

wengwashere
04-13-2004, 11:25 PM
You could split the string again into two by using the " " as your delimiter. Provided that, your first field does not contain any " "

Tamaraw
04-13-2004, 11:50 PM
You can also use the column property of a combo box.

'************

With cmbO
.AddItem '001'
.Column(1, .ListCount - 1) = 'Smith'
'etc. or supply values using your recordset
end with

cmbO.BoundColumn = 1 'Or column # you like to bound the combo box
txtX = cmbO.value

'*************

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum