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
LVL 119

Expert Comment

by:Rey Obrero
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?

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 ...!

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.


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 39

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 - Access MVP) 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
count unique records in access report 2 23
Syntax Error in Query 7 30
Open CSV, modify and save as xls from Access 12 19
Access Excel export not behaving 2 25
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
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…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

914 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

16 Experts available now in Live!

Get 1:1 Help Now