|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Can anyone tell me how I can have a combobox reflect data that is in my database?
Example. tblModel contains PK->Model_ID, - autonumber and ModelDesc - text. Now the table holds of course, a model number and the description of that model number. I have no problem filling the combobox, it is when I set the box to a desired ModelID . My code is such... cboModel.ListIndex = rsModel!ModelID This code works fine if your table entries are never deleted , everything works great but if you delete a model, say no.1 then your tblModel.ModelID now starts at 2, this is where the combobox screws up because if you try to use ListIndex with only the one entry in the table, you get an error trying to send an invalid value. My question is how do I use the ItemData property to use the ModelDesc and set my combobox to that rather than the short coming of the ListIndex? If I have confused you with my post, its only because I am learning VB and although I know what I need to do, I am having a hard time explaining what I am trying to do. Hopefully someone can understand my gibberish. Thanks in advance. |
|
#2
|
|||
|
|||
|
The only way to ensure this is to delete the entry from the combo at the same time you delete from the database. If you deliberately do not want to delete from the combo, then you should re-design your app so that perhaps you have a second combo listing those that have been deleted and simply move the deleted entry from the original combo to the combo holding those that have been deleted.
|
|
#3
|
||||
|
||||
|
have you tried clearing the list and then reloading it completely. I normally don't handle combo boxes in this way, so I'm really just guessing.
__________________
Fisherman "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > ComboBox problems???? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|