Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Unable to select Combo on update of record

Posted on 2014-12-31
6
Medium Priority
?
156 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 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 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 85
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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 31

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

783 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