10-19-2004, 04:05 AM
i have a database with conaining names. and im making a visual basic program to edit/view/add records in that database. one of the fieilds in my database contains names. i want to be able to read all the names from the database and add them to a dropdown box in my vb program so that when a different name is selected from the dropdown, all the information for that name is displayed on my form
how would i go about this
10-19-2004, 04:20 AM
Have you tried to search the forum? This (fill listbox/combobox question) has been asked many times...
10-19-2004, 04:30 AM
yes i have searched, i couldnt find what i was looking for. any suggestions?
i have the basic idea down:-
for i = 1 to 10 ' there are 10 records in the database field and i has been declared as an integer
frmassign.LstDrivernames.addnew .(dont know what to put here?!?!)
if eof = false then
10-19-2004, 06:12 AM
>.(dont know what to put here
10-19-2004, 07:12 AM
Since you already used the With function
You can do .Fields("FieldName").Value
10-19-2004, 08:04 AM
Just a tip.
You have to be carefull about what you "seeing" in your list box. Since you said that you're populating names there is a chance that these names may be repeated sometimes. So in your listbox you may see something like this
e.g.(3 NEO's here!)
In order to avoid this try to form your data a little bit before you add them to your list box.
.AddItem rs.Fields("name").Value & " " rs.Fields("surname").Value
.AddItem rs.Fields("id").Value & " - " rs.Fields("name").Value
Later you could use some string manipulation functions in order to retrive the desired value.
10-19-2004, 09:09 AM
ok thanks for your help you guys :)