Hello,

I have a form where I have to say two dropdown lists.
Firts dropdown list is populated based on query from a table in access database.
I have another dropdown list .I woud like in that second dropdown to show only values that are relevant to the selection in the first dropdown.
In my case first dropdown CedantID,
Second dropdown CompnayType.
So when a CedantID is selected I want in the second drop down to show the available company types for the currently selected Cedant ID.
Here is the Code I have:

Private Sub execute(ByVal CedantID)
        'handles getting the currently  selected data in controls

        Dim connSelCompType As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DB\DataStatusRecord1.mdb")
        Dim strSQL1 As String = "select  (CedantID,CompanyType) from (Recording) GROUP BY (CedantID,CompanyType)  having  CedantID=@CedantID ORDER  BY (CompanyType)"
        Dim cmd1 As Data.OleDb.OleDbCommand

        connSelCompType.Open()
        cmd1 = New Data.OleDb.OleDbCommand(strSQL1, connSelCompType)
        Dim da1 As New System.Data.OleDb.OleDbDataAdapter(cmd1)
        Dim dsCompanyType As New Data.DataSet
        da1.Fill(dsCompanyType)
        cmd1.ExecuteNonQuery()
        connSelCompType.Close()






    End Sub

I have the @CedantID specified to be the currently SelectedValue in the CedantId in the dsCompanyType select query property.

It doesn`t seem to work.
Am I missing something.
Do I have to have some more code in the index change event to make it happen.
Any help will be appreciated.

Thanks

Recommended Answers

All 2 Replies

hi,

r u getting values in second dropdown .what error r u getting

The problem is I got the same value over and over again. No matter what is selected in the first dropdown the value in the second dropdown is the same . Also when debugging I get no errors.
I deleted the dropdown and recreated it again. Now it works but will have to work when the second dropdown get`s polpuated. I want it to be as soon as soemthing is selected in the first dropdown.
I should probably write some code in the index changed event .

Thank you for reply
P.S I thought the post was removed because it was duplicate. Not sure how did it reapear

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.