Solved

Unable to select Combo on update of record

Posted on 2014-12-31
6
148 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
Independent Software Vendors: 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 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

Independent Software Vendors: 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!

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
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.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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.

756 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