Unbound form control won't requery/refresh

Posted on 2011-02-15
Last Modified: 2012-05-11
I have been working for an entire day at getting a single unbound control to requery. Refresh. whatever.

A single form.
2 combo boxes.
1 is populated and woolah!
The second one is filtered to the results limited by the 1st combo box's selection.

I've done this type of reference a hundred times but this time I can't get the darn combo box #2 to actually requery itself to the results of the newly changed combo box #1. Both are unbound. Both are on the same form. Both are enabled, visible, unlocked.

Funny, the sql query on the rowsource for combo box #2 works great. The combo box doesn't.

I've tried access macros using actions:
runcommand with refresh, runcommand with run or just fun ol' macro action requery.

I've tried using different vba options:

I've tried putting the macros/vba on the after update event of combo #1.
As well as the on enter event, on got focus event, on click event for combo #2.

Problem with the on enter and on got focus events is that, combo #1's action can't set the focus to combo #2 when I use those. So I'm stuck with on click but I can't get it to work.

Please help me. This is my mountain. I must get over it!
Question by:culpees
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
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34903500
LVL 75
ID: 34903596
"The second one is filtered to the results limited by the 1st combo box's selection."
What is the Row Source SQL for the 2nd combo
What are the names of the Combo boxes?

You have a couple of options
1. After Update event of Combo 1

Private Sub Comb1_AfterUpdate()
End Sub

2.  On Enter event of Combo 2

Private Sub Combo2_Enter()
End Sub

If neither of these work, then something unusual is going on, like the Row Source for Combo2 is not correct.


Author Comment

ID: 34903611
I read this article. I'm keeping it for prosperity. But I don't see how my exact scenario fits in.

I could apply the row souce using cases in vba BUT if we apply more options to the table, then I'd have to manually adjust the vba as well to include the additional case options. This is out of the question.

The row source is defined already and works outside the combo. It actually works in the combo the first time you activate the form. But then once you click on it after updating the combo1 it doesn't reflect the change seen in combo1.

And, bonus.
Combo 2 needs to remain UNFILTERED at all if combo 1 is blank. so my query is seen below:

So if combo1 is null, the query returns all records. If combo 1 has a selection, it limits the records.

Why if the query works won't the combo requery?
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.


Author Comment

ID: 34903627
wow. good timing mx.

combo 1 = cmbTeam
combo 2 = cmbSPASelect

on option 1 you posted:
did you mean literally to requery combo1? not combo2?
LVL 75
ID: 34903630
typo sorry

Private Sub Comb1_AfterUpdate()
End Sub

Author Comment

ID: 34903644
okay. well I tried both. Those were initial efforts too actually. No go.

What's next? Please tell me there's more???
LVL 75
ID: 34903658
Can you upload the db ... or a one that exhibits the issue ?


Author Comment

ID: 34903783
Sure thing!

I made a substitute database which is seen attached here. It has the applicable form, tables, macros and queries in it.

It is stripped of proprietary data but there is enough there to test it and see what it is doing. I was able to replicate the problem with this copy.

Option 1. Team Rep ("combo 2") needs to be unfiltered. Click on Team Rep to get a full list. (IF the Team Rep has a profile set up as indicated by fields in the underlying table for that control, that selection will then populate the 3 boxes to the right including "combo 1" (Team).)

Option 2. Team Rep ("combo 2") needs to be filtered based on Team ("combo 1") selection.

So basically an "if". If [Team] has a selection in it, then limit "Team Rep", else no limitation.

((You'll get a "REGISTRY" form error when opening the main form. It's because that form is a subform which is not included in this database since it's not affected by my immediate problemo.))

Thank you so much for looking at this!!!!!
LVL 75
ID: 34903806
the db/txt file is zero bytes ...!


Author Comment

ID: 34903823
Okay. this time it took it. I don't know what happened.
LVL 75
ID: 34903854
Ok ... can you tell me the exact steps ....with current results and expected results.  IE ... do this, then that ... specifying what values to select ... and what should be the results.

Author Comment

ID: 34903886
1 of 2 things should happen.

(Team is null and not populated.)
Click Team Rep and see a full list, unlimited. This is good.
Make a selection (example, SP or GG). If user has a profile set up, then you'll see the 3 fields to the right populate. (The Team populates for all users though the Area and Asset may not be set up for everyone's profile yet.)

So in short. The Team Rep selection from an unrestricted list will populate the Team as well as the Area and Asset.


Let's say Team is populated now, due to a previous search. This is good.
I want to go backwards now.
Click Team Rep, and now this list should be restricted by the Team selection (only because the Team is not null and actually has a value in it.)

# 2 is the part I can't get working. I want to be able to click the Team and then go to the Team Rep and see that list become limited to whatever is selected in Team if it has something selected. Otherwise the Team Rep needs to remain a full, unlimited list if Team is empty.

Author Comment

ID: 34903897
Currently, for part 2... Team will have a value in it and I click Team Rep to see the limited list but it's not filtering. The Team Rep filter will work 1 time once you activate the form. After that, you can change the Team and then go to the Team Rep and see no change in the list even after the Team has been changed.

Sorry, forgot to mention what it is currently doing.
LVL 75
ID: 34903918
"Currently, for part 2... Team will have a value in it and I click Team Rep to see the limited list but it's not filtering."

Seems to me that is is filtering - see images.

What am I missing ?
LVL 40

Expert Comment

ID: 34904038
In Afterupdate event for field cmbTeam, add requery for field cmb.SPASelect

Private Sub cmbTeam_AfterUpdate()
LVL 75

Accepted Solution

DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 250 total points
ID: 34904066
See if this is closer to what you want ...


Author Comment

ID: 34907122

I can see that you switched the code in the after update on combo1. I swear I had that before and it didn't work then! I'm glad it's working now. It appears to be doing exactly what I want it to do now. So I've replicated it to my actual db and we're good to go.

I am so pleased. Thank you for helping me last night. That was fantastic.

LVL 75
ID: 34908658
You are very welcome.
Thank you for using Experts Exchange.


Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

630 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