Solved

How to Change Combobox Recordset Source

Posted on 2004-04-25
6
702 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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
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.

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

738 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