Hello everyone i am a student who has very little knowledge about programming.
I would like to know if there is a way to load list from a database to a combo box.
there are two fields in my database namely: Age and Allowance.
what i want is to load age in the combo box.then i will have the textbox locked.when i choose an age in the combo box i want the text box to show the equivalent allowance for the age.. is that possible?

and how?

for example:
in my database the field Age has: 10,11,12,13,14,15,16
and the allowance i have: 50,60,70,80,90,100,110

as i have said earlier i want to load the data of Age in the combo box
and when i choose an age (e.g. 10) i will get the equivalent allowance (in this case 50)

thank you and God Bless.

i assume you have declared all variables and database paths
do something like this..

private sub showdata()

set rs=new adodb.recordset ' that is if you have referenced it and declared it
along with db or any other for database
rs.cursorlocation=aduseclient
rs.open("select * from <your table name> where age=" & <combobox name.text>),<database name>,adopendynamic,adlockoptimistic
if rs.recordcount >0 then
<your textbox name.text>=rs.fields("<your allowance field name>")
else
<your textbox name.text>=vbnullstring
endif

end sub


CIAO

what i want is to load age in the combo box.then i will have the textbox locked.when i choose an age in the combo box i want the text box to show the equivalent allowance for the age.. is that possible?

very possible, lets see what you've got

As long as the fields are in the same rowset, you shouldn't have a problem. So if your recordset, for example, is the Customer Table and that table has Age and Allowance fields, then you can bind the combo box and the textbox to a data control.

Here's the procedure:

(1). Add a data control to your form.

(2). Set the connect property, the database name, and the recordsource properties of the data control in the property box of the data control at a minimum. The record source should be the row that contains the values you're looking for: Age and Allowance.

And (3). Bind the combo and text box controls to the data control. Set the Data Source property to the name of your Data Control (Data1?), and the DataField to Age (for the Combo) and Allowance (for the Text Box).

All you have to do is click on the arrows of the Data Control and the values should
change automatically as long as you have the controls set up properly.

This article has been dead for over six months. Start a new discussion instead.