fill combo boxes using ado database
i am using three combo boxes such as
cmb_class,cmb_div and cmb_rno.
i have done with filling the combo indivisually.. but i want user to select the class first.
then the list should be generated in div (i.e. division) combo according to class.
Means, if 5th class having 4 divisions it will show same and so on..
help me...
thnks inadvnce
Re: fill combo boxes using ado database
Welcome to VBForums :wave:
As you have left out lots of details (such as the language you are using, your code, the table/field details, etc) we can't be precise, but what you want is an SQL statement like this:
Code:
strSQL = "SELECT div FROM division WHERE class = '" & cmb_class.Text & "'"
..which you would use to load the data in the second combo when an item is selected in the first.
Re: fill combo boxes using ado database
thanks 4 the quick reply...:o
i have done with the solution of that problem ...
if i am not irritating you, can i ask you for little more help?
Now i want to fill third combo as per these two..
i.e.
cmd.commandtext="SELECT student FROM students WHERE class = "cmb_class.text " and div = "cmb_div.text"
plz do the needful......:afrog:
Re: fill combo boxes using ado database
You should be able to work that out yourself (or at least get close to it) based on my example... give it a try :)
Re: fill combo boxes using ado database
i tried an sql statement for it with AND but it is givng error msgs like Typemismatch or No Value given for one or more parameters required....
one of the statements i used was
___________________________________________________________________________________
cmd.CommandText = "Select STD_INFO.* from STD_INFO where [Std_Class]= " & CMB_CLASS.Text And " [Std_Division]= ' ' " & CMB_DIV.Text
___________________________________________________________________________________
STD_INFO is table name, and i am using db access 2000(.mdb) with adodb.connection
Re: fill combo boxes using ado database
Is Std_Devision a text field in the database? Why do you have an open and close text deliminator in the query and then append a text value after that?
Re: fill combo boxes using ado database
finally i hav don with this as:
Code:
Private Sub cmb_div_click()
rst.MoveFirst
If rst![Std_Division] = CMB_DIV.Text Then
CMB_RNO.AddItem rst![Std_Roll_Num]
End If
End Sub
i.e. it fills only those items(roll numbers) from an open recordset where the division is equal to CMB_DIV.text..