[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Simple Combo Drill Down Query

Posted on 2013-06-13
14
Medium Priority
?
276 Views
Last Modified: 2013-06-15
Hi,

(This is one I should be able to sort myself .... but I'm struggling).

One Continent has many Countries.  One Country has many cities.

See frmCountry.   The allows me add new "Countries" to pre-setup "Continents".

frmCity is the problem!!
When I choose a continent in frmCity I want the "Country" (in yellow) to show ONLY countries in the chosen continent.  
HOW do I restrict the "country" combo?

(By the way, I have tried using Forms!frmCity!Continent etc but failed).
Database1.accdb
0
Comment
Question by:Patrick O'Dea
[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
  • 8
  • 6
14 Comments
 
LVL 28

Expert Comment

by:omgang
ID: 39245136
Two things.

1) You've got the wrong column specified as Bound Column for the ContinentC combo box.  Change the BoundColumn property to 0

2) Set your SQL statement for the RowSource of CountryC combo box to
SELECT tblCountry.CountryID, tblCountry.CountryName, tblCountry.Continent FROM tblCountry WHERE (((tblCountry.Continent)=[forms]![frmCity]![ContinentC]));

OM Gang
0
 

Author Comment

by:Patrick O'Dea
ID: 39245192
OM,

I have tried your suggestion but I am getting nothing displayed in the "yellow" Combo.

Any chance you could email me back a working database with the changes your suggested.

I appreciate your help.
0
 
LVL 28

Expert Comment

by:omgang
ID: 39245387
Modified db attached
OM Gang
Database1.accdb
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 28

Expert Comment

by:omgang
ID: 39245425
I went back to double-check and see that it's not working as expected.  Hold please.
OM Gang
0
 
LVL 28

Expert Comment

by:omgang
ID: 39245440
We need to requery the CountryC combo box after each change to the ContinentC combo box.  Add the following code to the form (it's an AfterUpdate event procedure for the ContinentC combo box).
OM Gang

Option Compare Database
Option Explicit


Private Sub ContinentC_AfterUpdate()

On Error GoTo Err_ContinentC_AfterUpdate

    Me.CountryC.Requery

Exit_ContinentC_AfterUpdate:
    Exit Sub

Err_ContinentC_AfterUpdate:
    MsgBox Err.Number & " (" & Err.Description & ") in procedure ContinentC_AfterUpdate of VBA Document Form_frmCity"
    Resume Exit_ContinentC_AfterUpdate

End Sub
0
 

Author Comment

by:Patrick O'Dea
ID: 39245537
Sorry OM,

It's still not working for me.
I attach my amended database.

Perhaps I am missing something?
Database1.accdb
0
 
LVL 28

Expert Comment

by:omgang
ID: 39245968
For ContinentC combo box, change the BoundColumn property back to 1.  I gave you bad advice previously.

OM Gang
0
 

Author Comment

by:Patrick O'Dea
ID: 39245988
OM,

No joy with the change of the BoundColumn.  I still get nothing when I dropdown on the yellow country combo.
0
 
LVL 28

Expert Comment

by:omgang
ID: 39246026
I think that's the only change I made.  I've attached the db.
OM Gang
Database2.accdb
0
 

Author Comment

by:Patrick O'Dea
ID: 39246056
OM,

....not there yet , I'm afraid.

The combos now seem to work and indeed the data seems to get written to the table.

However, if I close the form and then re-open and then click thru the records .... the data does NOT show.    aaaagh!
0
 
LVL 28

Expert Comment

by:omgang
ID: 39246092
When the form opens it is on the first record in the datasource (which is tblCity).  If I select a Continent and then a Country and then enter a value for City and then move to the next record (new record) the city value is saved to the tblCity table with the appropriate Country ID.  If I then re-open the the form it opens to the same first record, now populated with the city I entered previously.  Based upon your design this is working correctly but it's not what you want.
The Control Source for CountryC is CountryID from tblCity but the Row Source says to only display values for the ContinentID displayed in ContinentC.  When we open the form there is nothing in ContinentC so the CountryC combo box displays nothing.
I think I understand how you want the form to function.  I'll make some changes and repost.  Probably won't be until tomorrow.
OM Gang
0
 

Author Comment

by:Patrick O'Dea
ID: 39246115
Thanks again for your time and patience.
0
 
LVL 28

Accepted Solution

by:
omgang earned 2000 total points
ID: 39247973
Take a look at frmCity in the attached db.  I believe this functions as you desire.  I changed the CountryC combo box to be unbound and added two new controls to the form (you could make one or both invisible).  The CountryID textbox is bound to CountryID.  The other textbox is unbound and is used to display the CountryName value based upont the CountryID assigned.
OM Gang
Database2.accdb
0
 

Author Closing Comment

by:Patrick O'Dea
ID: 39250014
Great thanks,
I finally got it working.

Thanks again for all your effort.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…

649 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