Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to Change Combobox Recordset Source

Posted on 2004-04-25
6
Medium Priority
?
709 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 750 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

664 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