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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help! Getting Values from Cascading Listboxes

Status
Not open for further replies.

Lourry

Technical User
Jul 25, 2003
84
CA
Hello All,

I have 2 cascading listbox working and since I am working from an already existing database in Oracle, I want the new form that I'm creating to save as the same format as before using another application.

In the first listbox, it has items:
IBM
Sony
Compaq
Dell

In the second listbox the items varies according to the value chosen in the first listbox.

SO, for example if the user choose Sony in the first list and Laptop from the second list. The data should be saved as Sony-Laptop, where the selected values from each listbox is concatenated with a hypen in between and saved to a Oracle table.

How can I achieve this? Should I create another textbox that purely does the concatenation and use that textbox and bound it to the field in Oracle table? Also, when retreiving records, if the data is saved as Sony-Laptop, can I do some coding so that the proper items in the listbox is highlighted?

Thanks in advance!

-Lory
 
This is not how I would have designed it but you sometimes have to live with what you've got.

yes you can do the concatenation in a textbox

to code it to select the valus in the listbox you will need to use instr() and mid() to parse the strings from the current record then go thru the listboxs items and set their selected to true if it matches an item in the list

you may want to do this with a combobox instead

 
Thanks Gol4!!

Given the information in my first post. Can you teach me how to use instr() and mid() to parse the strings so the correct value is highlighted in each listbox?

Please??? I'm a beginner in Access.

Thanks a lot! Really appreciate the help as I'm really desparate to get this working!

-Lory
 
Sorry for slow response took a long weekend

code like this will select the items in the field

first you will need to parse the string
get everything left of the -

leftvariable = left(fieldname,Instr(fieldname,"-")-1)

then right of

rightvariable mid(fieldname,Instr(fieldname,"-")+1)
'select items in list1
Dim varitm As Integer
For varitm = 0 To List1.ListCount - 1
If InStr(leftvariable, List1.ItemData(varitm)) Then
Me.List1.selected(varitm) = True
End If
Next
'select items in list2
For varitm = 0 To List2.ListCount - 1
If InStr(rightvariable, List2.ItemData(varitm)) Then
Me.List2.selected(varitm) = True
End If
Next


 
Thanks a lot gol4!!

I'll give it a shot. Thanks a lot, you saved my day!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top