Solved

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

Posted on 2014-09-11
6
270 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

760 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

19 Experts available now in Live!

Get 1:1 Help Now