Solved

i have problem with comboboxes

Posted on 2004-10-18
4
154 Views
Last Modified: 2010-04-23
Dear Experts,

i need a solution to the above problem.
I have two combobox the first combobox called Periphery and the second called county.
I want to do this : When i select a specified periphery from the first combobox i want the second combobox to give the specified county which belongs to the periphery..

the periphery and county get the fields from the tables from the database..
Please i need help...
0
Comment
Question by:dakanali
4 Comments
 
LVL 10

Accepted Solution

by:
123654789987 earned 25 total points
ID: 12337216
U can see the following link. It shows the relationship between a combobox and a listbox. U can implement the same with two comboboxes

http://codeproject.com/cs/miscctrl/valuemembersample.asp
0
 
LVL 19

Assisted Solution

by:arif_eqbal
arif_eqbal earned 25 total points
ID: 12337321
On SelectedIndexChanged of first ComboBox write the code to populate the other Combo


    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged


        Dim DR As OleDbDataReader
        Dim Cn As OleDbConnection = New OleDbConnection(YourConStr)
        Cn.Open()
        Dim Cmd As OleDbCommand = New OleDbCommand("Select YourCol From Yourtable Where AnotherCol='" & ComboBox1.Text & "'", Cn)
        DR = Cmd.ExecuteReader
        Do While DR.Read
            ComboBox2.Items.Add(DR(0))
         Loop

        DR.Close()
        Cn.Close()

End Sub


However this will require a roundtrip to the dataBase so you can as well store all data in a dataTable and locally populate the combobox

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now