Results 1 to 7 of 7

Thread: fill combo boxes using ado database

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2010
    Posts
    4

    Thumbs up 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

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: fill combo boxes using ado database

    Welcome to VBForums

    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.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2010
    Posts
    4

    Red face Re: fill combo boxes using ado database

    thanks 4 the quick reply...
    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......

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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

  5. #5

    Thread Starter
    New Member
    Join Date
    Jun 2010
    Posts
    4

    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

  6. #6
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    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?
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  7. #7

    Thread Starter
    New Member
    Join Date
    Jun 2010
    Posts
    4

    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..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width