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
Solved

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

Posted on 2014-09-11
6
275 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

809 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