running a code from Button is slower then from label (1 Viewer)

smig

Registered User.
Local time
Today, 22:31
Joined
Nov 25, 2009
Messages
2,209
I recently noticed that running the exact same code from a button click is by far slower then running it from a Label click :eek:

I noticed that if run a sort it will load the turning wheel at the end of the run after all data is sorted and set, while running it from a button.
This action alone takes time :confused:

Any idea ?
 

Frothingslosh

Premier Pale Stale Ale
Local time
Today, 16:31
Joined
Oct 17, 2012
Messages
3,276
I've never run into that before. What was the load on your computer at the time? The only thing I can think of offhand that's different between the two is that the button click involves a small animation plus recoloring of the button.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 15:31
Joined
Feb 28, 2001
Messages
27,001
There is documented behavior regarding the difference between clicking a command button and clicking something else.

https://support.office.com/en-us/ar...-objects-e76fbbfe-6180-4a52-8787-ce86553682f9

Relevant section is "Order of events for keystrokes and mouse clicks" which is down a ways into the article. Does this click involve the potential of changing the current record? Because the Current event sneaks its way in when that happens.

Is there a chance that the click would be seen as a double-click? (I.e. are you heavy-handed when clicking such that the mouse might "bounce"?) Because in THAT case, you get THREE clicks (single-double-single). This wouldn't happen for a label. Perhaps it wouldn't hurt for you to put some breakpoints in the click routine to see just how often it is called.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 16:31
Joined
May 21, 2018
Messages
8,463
My guess it is more a coincidence related to something else then directly related to the button and label. Sometimes code does not compile cleanly. You could try to decompile and recompile. You can Google how to do this. One thing you could try is deleting the button and adding a new button. I would give it a new name. Another thing could be the location of the two controls and events that occur moving to these controls, especially if different locations (example subform vs mainform). You may want to add DoEvents add the beginning of the button code. There may be a hanging event that is not occuring until your code completes.

This does sound strange, so my guess would be a compile issue and could get worse. You may want to just go ahead and decompile to be safe if a new button and doevents does not help.
 

smig

Registered User.
Local time
Today, 22:31
Joined
Nov 25, 2009
Messages
2,209
My guess it is more a coincidence related to something else then directly related to the button and label. Sometimes code does not compile cleanly. You could try to decompile and recompile. You can Google how to do this. One thing you could try is deleting the button and adding a new button. I would give it a new name. Another thing could be the location of the two controls and events that occur moving to these controls, especially if different locations (example subform vs mainform). You may want to add DoEvents add the beginning of the button code. There may be a hanging event that is not occuring until your code completes.

This does sound strange, so my guess would be a compile issue and could get worse. You may want to just go ahead and decompile to be safe if a new button and doevents does not help.
I noticed it after I replaced a label with a button (I wanted the button Hoover effect)
It happen in more then one place.

They both run exactly the same code. It doesn't netter if the code is a form's subroutine or a function run by .OnClick event.

It does happen when the record set is updated
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 16:31
Joined
May 21, 2018
Messages
8,463
Strange, I never seen this or heard about this. Did you try adding DoEvents at the front of the button code?
 

Micron

AWF VIP
Local time
Today, 16:31
Joined
Oct 20, 2018
Messages
3,476
I was going to echo the comment about this being a coincidence and suggest that smig post the code in case a review might find issues with it but decided to wait. If there's nothing obvious there, I wondered if Track Changes could have anything to do with it. It's just that TC could come in to play when a control has been replaced but that seems like a real stretch.

I would agree that a decompile should be performed (perhaps on a copy, just in case) before anything else is done lest effort and time gets wasted looking for something that might be fixed by doing so.
 

Users who are viewing this thread

Top Bottom