Solved

How can I stop a combo box flickering when the On GotFocus event fires?

Posted on 2014-09-11
6
272 Views
Last Modified: 2014-09-13
I have a combo box with an On GotFocus event that simply does a me.activecontrol.requery. The intention is to refresh the rowsource of the list before the user makes a selection. Whenever I click on the combo box of a new record the list briefly appears then disappears. I then need to click a second time to bring up the list. Is there any way to requery the rowsource without having the list appear and disappear?
0
Comment
Question by:Rob4077
  • 3
  • 2
6 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 total points
ID: 40317013
Are you sure you need to requery the control that often? If you're adding records that could affect the data displayed in the control, then you might be better off requerying the control when you finish that process (i.e. when you finish adding the data).

That said, you can always try turning off the Echo:

Application.Echo False
<do your work>
Application.Echo True

If that doesn't work you can use the API:

Put this in the General Declarations section of a Standard Module (i.e. NOT a form):

Declare Function LockWindowUpdate Lib "user32" (ByVal hWnd As Long) As Long

Now call it when needed:

LockWindowUpdate Me.Hwnd
<do your work>
LockWindowUpdate 0

Just be SURE that nothing interferes with the "LockWindowUpdate 0" line. If your code fails before that line, the application will appear to hang, since Windows will stop updating the display. Same with the Echo methods - if you fail to run Echo back on, the application will appear to hang.
0
 
LVL 10

Assisted Solution

by:WayneATaylor
WayneATaylor earned 250 total points
ID: 40317099
The problem with a requery is it will always clear the list then re populate it.

Rather than requery on getfocus, can you do the requery say when another field is updated or even on a timer?

Making sure to add code to not requery if the combo list is open.

Thanks
Wayne
0
 

Author Comment

by:Rob4077
ID: 40318780
Thanks for your suggestions.  I had hoped there was another way but I will find a way to make it work as you suggest.
0
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.

 
LVL 84
ID: 40319001
What was the solution for this?
0
 

Author Comment

by:Rob4077
ID: 40320696
For me the easiest solution was the one you both suggested: "you might be better off requerying the control when you finish that process" and "requery say when another field is updated ". I am requerying the controls whenever a change is made to the source data instead of when the control is selected. That's why I shared points. Thanks
0
 

Author Comment

by:Rob4077
ID: 40320697
BTW I tried the echo command but it didn't stop the flicker.
0

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

896 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

17 Experts available now in Live!

Get 1:1 Help Now