If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > ADO recordsource changing in combobox

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-12-02, 04:02
Kaag Kaag is offline
Registered User
 
Join Date: Nov 2002
Location: Rotterdam, Holland
Posts: 1
Exclamation 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 ?
Reply With Quote
  #2 (permalink)  
Old 01-02-03, 11:09
roman22 roman22 is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 01-19-03, 11:26
Ad Dieleman Ad Dieleman is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On