Solved

How to Change Combobox Recordset Source

Posted on 2004-04-25
6
701 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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