Solved

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

Posted on 2014-09-11
6
276 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

749 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