Solved

Unable to select Combo on update of record

Posted on 2014-12-31
6
151 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
[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 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Outlook 2016 VB code syntax 4 37
Add Underline to custom Caption on Label 4 35
SUBFORM on ACCESS 2013 8 34
Speed up Select Top n... Query 9 36
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.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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.
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…

734 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