Solved

How to Change Combobox Recordset Source

Posted on 2004-04-25
6
698 Views
Last Modified: 2010-08-05

I'm using the Recordset property off a combobox to populate the combobox from an ADO recordset.  I do this for a lot of my quasi-static lookup lists by saving persistent ADO recordset files on the front ends of the data base.   It works well, except for when I try to change the recordset and then re-set the combobox Recordset property.  (Simple example:  change a State lookup list from the 51 USA states to the 13 Canadian provinces/territories based on a country selection).  The combobox doesn't seem to "take" the new values of the changed recordset.  Its dropdown list either displays all blanks or simply displays the orginal recordset values.

I've tried to use ADO methods (like .Delete, .AddNew and .Update) directly on the combobox recordset object.  I've also tried to first set the combobox recordset object to Nothing, and then set a new/changed recordset to the combobox recordset object.  Neither seems to do the trick, nor other variations.

Any ideas?  

Thanks,
Wyatt

0
Comment
Question by:WyattRidesAgain
6 Comments
 
LVL 11

Expert Comment

by:Mighty_Silly
ID: 10912375
What is the code you use for "changing" the combo box's recordsource?

-Silly-
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 10912461
You don't use recordsource property bu the RowSource

Private Sub Form_Load()

Me.Combobox.RowSource= "Select fieldname From Table"
0
 
LVL 54

Expert Comment

by:nico5038
ID: 10912463
Did you issue a me.requery to get a fresh form ?

Nic;o)
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 119

Expert Comment

by:Rey Obrero
ID: 10912478
If you want to change RowSource on command button click

Private Sub commandChange_Click()
Me.ComboBox.RowSource=""         'Clears Row SOurce
Me.ComboBox=""                          'Clears box display
Me.ComboBox.RowSource=Select Fieldnames Form Table"




End Sub
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 250 total points
ID: 10917845
<(Simple example:  change a State lookup list from the 51 USA states to the 13 Canadian provinces/territories based on a country selection).>

Here is how to do this;

Private Sub Form_Load()
Me.cboCountry = ""
Me.cboCountry.RowSource = "Select Distinct Country From TableName"
End Sub

Private Sub cboCountry_AfterUpdate()
Me.cboState=""
Me.cboState.RowSource = "Select Distinct State From TableName " & _
                        "Where [Country]= " & Chr(34) & Me.cboCountry & Chr(34) & " "
End Sub
0
 

Author Comment

by:WyattRidesAgain
ID: 10937476
I'm sorry for not responding:  I've been pulled away on some emergency work.  Unfortunately I can't chase this further right now, and may have to re-post the question later.  Let me give out the points so you're not left dangling.  From the quantity of info provided, it seems fair to give capricorn the points.

Thanks for the fast answers!  Sorry we can't conclude this at this point.

Regards,
Wyatt
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

867 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