Solved

Unable to select Combo on update of record

Posted on 2014-12-31
6
139 Views
Last Modified: 2015-01-19
I have a sample db - with Select Combo builts results for next combo then returns record result on selection of the City Combo.  This all works find, except I am unable to change the Selection for the Country Combo (First Combo) Form1.  Sample attached.  I am using VBA to set combo values.

What am I missing?

karen
Database2.accdb
0
Comment
Question by:Karen Schaefer
6 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 40525924
The GotFocus event of your Country combo is throwing the focus to txCity, for some reason. What's the reasoning behind this code:

 If Me.Country <> Me.Country.ItemData(1) Then
        Me.txtCity.SetFocus
Else
        Me.Country = Me.Country.ItemData(1)
        Me.Country.Dropdown
End If

Essentially, you're disallowing focus if the value of the combo is anything other than the first value in the combo's list, which makes no sense. Comment out that entire block of code, and it should work.
0
 

Author Comment

by:Karen Schaefer
ID: 40525952
I was trying to prevent the drop down expandtion on the second pass on selection of the city it is going back to the Country combo  and drop down expands, I need to set focus to the TxtCity, but still be able to make another selection form Country combo.  when I removed the above mentioned code.  this is what happens.

What I a attempting to do:
1.  Select a Country, have dropdown expand on open or onselect of the Country Comob.
2. If Country = 'USA', then display state combo
3. On afterupdate of State, display and expand the list of cities for the particular state selected.
4. Return records for that city.
5.  Allow user to make another Country seelction and repeat the process. Display/Hide as need any of the fields.

Pleae feel free to modify my code to simplify this process.

Thanks,

Karen
0
 
LVL 84
ID: 40525972
I'm not sure if you can effectively dropdown when the combo is selected, so won't go there, but:

In the Open event of the form, clear the RowSource for the State and City combos. This disallows users from selecting a City before they select a State, and a State before they select a Country.

In the Country's AfterUpdate event, set the rowsource for the State, if they select USA. If not:

Me.State.Visible = Me.Country = "USA"

And then set the RowSource for the City for the selected Country.

If USA is selected, then in the State's AfterUpdate, set the RowSource for the City.

In other words, you'd only clear out the values in State and City when the user selects a different value in the Country combo.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 30

Expert Comment

by:hnasr
ID: 40526094
Tell us in steps what to do and what to expect starting from opening the form, and show where is the problem.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40532467
At what point did this start to "Not work"?

If I comment out the code on the "got focus" event of the country combobox, ...
Then I am able to continue making selections...

...Also not really sure what your Before update code is doing there either...

So, you will have to explain to us what all the code there is supposed to be doing...?

Also, note that It would be simpler if you did not have separate "state" search logic.
The search for all countries could most likely be simplified to:
Country-->State/Province-->City


JeffCoachman
0
 

Author Closing Comment

by:Karen Schaefer
ID: 40558627
THANKS
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
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.
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…

706 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

20 Experts available now in Live!

Get 1:1 Help Now