Click to See Complete Forum and Search --> : How do you link an item to a item in a combobox
CCDriver
March 27th, 2001, 06:15 AM
Can someone point me to an example on how to link some items in textbox's to an item in a combo box when it's selected or show how it's done please.
I have five textbox's with variable data in them and they need to associated to an item in the combo.
shree
March 27th, 2001, 06:47 AM
Can you clarify your question please.
coolbiz
March 27th, 2001, 08:29 AM
This question is not that clear but anyhow, each items in ComboBox has an INDEX associated with it. You can save this INDEX into the TEXTBOX .Tag properties or something like that to link that TEXTBOX with the item in the ComboBox.
-Cool Bizs
CCDriver
March 27th, 2001, 04:58 PM
Ok, thank you Cool Bizs. I'll have a go but do you know if there is an example somewhere?
Thanks
coolbiz
March 29th, 2001, 09:36 AM
I can give you a sample code on assigning the INDEX property of the combobox to the TAG property of the textbox but not sure if it applies to what you are doing right now.
private Sub cmbItem_Click()
' assign listindex to the TAG so that we know which item to modify later
if (cmbItem.ListIndex <> -1) then
txtModifyItem.Text = cmbItem.List(cmdItem.ListIndex)
txtModifyItem.Tag = cmdItem.ListIndex
end if
End Sub
private Sub txtModityItem_LostFocus()
' check if text is different from original value
if (cmbItem.List(cint(txtModifyItem.Tag)) <> txtModifyItem.Text)) then
' should confirm if user wants to save changes
cmbItem.List(cint(txtModifyItem.Tag)) = txtModifyItem.Text
end if
End Sub
Hope this helps,
-Cool Bizs
CCDriver
March 29th, 2001, 05:31 PM
Yes, thank you Cool Bizs, That is what i am trying to do. I'll give it a try and see if it will work ok.
Thank you very much.
CCDriver
March 31st, 2001, 05:54 AM
Hi Cool Bizs
I have been mucking around with this for the last couple of nights and it's close to what i want i think.
What it's doing is putting the item in the combo box (a company name) into the text box, which isn't quite what i wanted to happen.
What i have is a combo box and five textbox's. The combo holds a company name and the textbox's hold the address of the company, when i select a company name in the combo i want the textbox's to show the address of that company.
I hope that is a little clearer this time.
Your code is close to what i need but i can't quite get it the rest of the way.
Can you help please?
coolbiz
April 1st, 2001, 11:58 AM
Sorry for this late reply. Anyway, I've coded a little sample for you:
http://coolbizs.20m.com/CodeGuruHelp/download/ccdriver.zip
Be sure to scan for viruses (i've done that 3 times before i uploaded it to the network) just in case the web space is not virus-free.
-Cool Bizs
CCDriver
April 1st, 2001, 06:30 PM
Hmmm, i get a permmission denied for access when i click on that link, Cool Bizs
Maybe somethings gone funny here, i'll try again tomorow.
coolbiz
April 2nd, 2001, 10:36 AM
Send me email personnally and i'll send you the package.
-Cool Bizs
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.