Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2002
    Location
    Rotterdam, Holland
    Posts
    1

    Exclamation Unanswered: ADO recordsource changing in combobox

    Thanks in advance for even reading my cry for help,

    I am trying to change the recordsource of an ADO data controller,
    by choosing an option from a combobox.

    this is the code I'm struggling to get to work:
    Private Sub cmbContact_dropdown()
    Dim cn As New ADODB.Connection
    Dim state As Integer
    Select Case state
    Case cmbContact.ListIndex = 0
    Set Recordset = Adodc1.RecordSource("InternetDataQuerytotaal")
    Case cmbContact.ListIndex = 1
    Set Recordset = Adodc1.RecordSource("MagazinesDataQuerytotaal")
    Case cmbContact.ListIndex = 2
    Set Recordset = Adodc1.RecordSource("NewspapersDataQuerytotaal")
    Case cmbContact.ListIndex = 3
    Adodc1.RecordSource = "PersbureauDataQuerytotaal"
    Case cmbContact.ListIndex = 4
    Adodc1.RecordSource = "PlayermanagersQuerytotaal"
    Case cmbContact.ListIndex = 5
    Adodc1.RecordSource = "PlayersDataQuerytotaal"
    Case cmbContact.ListIndex = 6
    Adodc1.RecordSource = "ReportersDataQuerytotaal"
    Case cmbContact.ListIndex = 7
    Adodc1.RecordSource = "WebmastersDataQuerytotaal"
    Case cmbContact.ListIndex = 8
    Adodc1.RecordSource = "AdvertisersQuerytotaal"
    End Select
    End Sub

    The unreadable stuff is Dutch, do not adjust your monitor...

    As you can see i tried something different for the first 4 options.
    Has anybody got a slightest idear how to pull this off ?

    Last but not least, how do i reload the combobox after an option is chosen ?

  2. #2
    Join Date
    Jan 2003
    Location
    Chicago, IL, USA
    Posts
    8
    Try this. Sorry if I'm way off base on what you're asking. Also, I'm not sure what you mean by reload the combobox.

    Private Sub cmbContact_Click()
    Select Case cmbContact.ListIndex
    Case 0
    Adodc1.RecordSource = "InternetDataQuerytotaal"
    Case 1
    Adodc1.RecordSource = "MagazinesDataQuerytotaal"
    Case 2
    Adodc1.RecordSource = "NewspapersDataQuerytotaal"
    Case 3
    Adodc1.RecordSource = "PersbureauDataQuerytotaal"
    Case 4
    Adodc1.RecordSource = "PlayermanagersQuerytotaal"
    Case 5
    Adodc1.RecordSource = "PlayersDataQuerytotaal"
    Case 6
    Adodc1.RecordSource = "ReportersDataQuerytotaal"
    Case 7
    Adodc1.RecordSource = "WebmastersDataQuerytotaal"
    Case 8
    Adodc1.RecordSource = "AdvertisersQuerytotaal"
    End Select
    End Sub

  3. #3
    Join Date
    Jan 2003
    Location
    Dordrecht, The Netherlands
    Posts
    95

    Re: ADO recordsource changing in combobox

    I don't know if this code can work it all, but you have to add the following line at the end of your sub, otherwise you won't see any changes anyway:

    Adodc1.Refresh

Posting Permissions

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