How to prevent screen flickering while scrolling in a form? (1 Viewer)

Sun_Force

Active member
Local time
Today, 09:55
Joined
Aug 29, 2020
Messages
350
I appreciate any advice on this.
A sample database is attached. If you open the database and use mouse wheel to scroll through the records
or
even if you select a record you'll notice screen flickers (flashes).

The form's recordset is a table.
There's no calculated field in form.
The only code behind form is Allen Browne's Mouse Wheel.
Even if I remove this function, there's no improvement.

The only thing that remains is Conditional Formatting.

Is there anything I can do to prevent screen flickering?

thank you.
 

Attachments

  • Database1.accdb
    5 MB · Views: 88

CJ_London

Super Moderator
Staff member
Local time
Today, 00:55
Joined
Feb 19, 2013
Messages
13,542
you can reduce (but not remove) the flickering by having a textbox sized to the detail section and sent to back. Then set the other controls backcolor to transparent. Then remove the conditional formatting from all these controls and apply to the new text box instead. Also recommend you disable the new control.

This means the conditional formatting is only determined once rather than many times.

I don't see the benefit of your orange formatting - all it appears to do is highlight the top row of the window. but that is the primary reason for the flickering, remove that and no flicker. You can still have it apply when a record is selected, just don't keep changing the value of txtcurrentrecord on the mousewheel event.

With regards the mousewheel event, pretty sure there is something newer than the code you are using - and if you read the provided documentation it is really intended for scrolling through records displayed on a single form , not a continuous form. From 2007 it is standard functionality to be able to scroll with the wheel on a continuous form.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:55
Joined
May 7, 2009
Messages
14,556
use Datasheet form.
it will flicker because of the way continuous form works (always RePainting the controls).
 

Sun_Force

Active member
Local time
Today, 09:55
Joined
Aug 29, 2020
Messages
350
you can reduce (but not remove) the flickering by having a textbox sized to the detail section and sent to back. Then set the other controls backcolor to transparent. Then remove the conditional formatting from all these controls and apply to the new text box instead. Also recommend you disable the new control.

This means the conditional formatting is only determined once rather than many times.
I'll try this and will come back to you again.

I don't see the benefit of your orange formatting - all it appears to do is highlight the top row of the window. but that is the primary reason for the flickering, remove that and no flicker. You can still have it apply when a record is selected, just don't keep changing the value of txtcurrentrecord on the mousewheel event.
I made a mistake in CF while I creating a test database.
There's 2 CF. One for highlighting the current record. One to select multiple records and run some queries on them. I'll talk to the owner if it's ok to remove the current record highlight CF.

With regards the mousewheel event, pretty sure there is something newer than the code you are using - and if you read the provided documentation it is really intended for scrolling through records displayed on a single form , not a continuous form. From 2007 it is standard functionality to be able to scroll with the wheel on a continuous form.
Good to know. I've inherited the db. So haven't gone through the remarks yet.

thanks for your time and helping.
 

Sun_Force

Active member
Local time
Today, 09:55
Joined
Aug 29, 2020
Messages
350
use Datasheet form.
it will flicker because of the way continuous form works (always RePainting the controls).
Will try this too to see if there's any change.
thank you.

EDIT : The owner of DB prefers continuous form. Seems that he doesn't like datasheet look.
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:55
Joined
May 7, 2009
Messages
14,556
continuous is more versatile as it can accept "fake" controls.

create a Test form using DS (subform to a Form).
compare the difference.
maybe present to the owner both forms and explain why the datasheet.
 

Sun_Force

Active member
Local time
Today, 09:55
Joined
Aug 29, 2020
Messages
350
you can reduce (but not remove) the flickering by having a textbox sized to the detail section and sent to back. Then set the other controls backcolor to transparent. Then remove the conditional formatting from all these controls and apply to the new text box instead. Also recommend you disable the new control.

This means the conditional formatting is only determined once rather than many times.

I don't see the benefit of your orange formatting - all it appears to do is highlight the top row of the window. but that is the primary reason for the flickering, remove that and no flicker. You can still have it apply when a record is selected, just don't keep changing the value of txtcurrentrecord on the mousewheel event.

With regards the mousewheel event, pretty sure there is something newer than the code you are using - and if you read the provided documentation it is really intended for scrolling through records displayed on a single form , not a continuous form. From 2007 it is standard functionality to be able to scroll with the wheel on a continuous form.
@CJ_London

  1. I'm not sure about previous versions of Access, but with my tests on 365 version, I can assure you mouse wheel works only and only if the vertical scrollbar is visible. If I hide the scrollbar because of the lack of space, mouse wheel doesn't scroll through records of a form unless I use the fucntion.
    I'm still searching for a newer version of the function.
  2. I followed your instruction on using only one text box behind all controls and work on CF for only one text box. But unfortunately the result is the same (or maybe worse). Would you please take a look at the sample DB attached to this post and see if I've done something stupid.
    Hit page down several times to see screen flickering.

thanks again.
 

Attachments

  • Database1.accdb
    2.5 MB · Views: 68
Last edited:

Sun_Force

Active member
Local time
Today, 09:55
Joined
Aug 29, 2020
Messages
350
create a Test form using DS (subform to a Form).
compare the difference.
I did. His problem with DS is that he can not multi select records and do some actions on them.
He needs to visually see which records are selected to be sure if the function is updating correct records, or he's mailing the correct data to the correct customer.

Thanks again
 

CJ_London

Super Moderator
Staff member
Local time
Today, 00:55
Joined
Feb 19, 2013
Messages
13,542
1, Curious - this is an old system yet only now the owner is concerned about the flickering

2. I was not suggesting remove the formatting for current row, just stop highlighting the top row

3. Hadn’t noticed about the scrollbar needing to be visible but you can hide it once the form is open, should still work

I don’t have much time this weekend but see if I can find the code - I use it in conjunction with mouse move
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:55
Joined
May 7, 2009
Messages
14,556
of course you can Highlight those records in datasheet view.
 

Attachments

  • Database1 (10).accdb
    2.9 MB · Views: 34

Sun_Force

Active member
Local time
Today, 09:55
Joined
Aug 29, 2020
Messages
350
@CJ_London
I'm not sure how old the system is. A friend of mine knows I'm interested in database and play with Access as a hobby. He (actually his father) asked me to look into this form.
As far as I tested the form, I can't see the first row being highlighted. Try the attachment in #7 post. If you see the first row highlighted, now we have another problem to solve. because the form doesn't behave the same on different PCs and environment.
For me, only current row is highlighted in orange, and selected rows in light blue.

I will check your suggestion on hiding the scrollbar once the form is opened on Monday. During weekend we are not allowed to go back to our classes, library or anywhere else. We are chained to our rooms because of covid. But I have a feeling if the scrollbar is not visible (through code after opening OR setting it on design mode) the mouse wheel will not work.


once again thanks for your help.
 
Last edited:

Sun_Force

Active member
Local time
Today, 09:55
Joined
Aug 29, 2020
Messages
350
@arnelgp

I don't have MS-Access on this PC. We are prisoners during the weekend and nobody is allowed to go out of dormitories.
Monday morning I will take a look to see how your magic works.

thanks again,
 

Sun_Force

Active member
Local time
Today, 09:55
Joined
Aug 29, 2020
Messages
350
Monday morning and we are back to our boring classes and listening to our professors nonsense.

One last question if I may.
Is screen flashing normal in Access continuous forms? or is it something wrong with this special form and its code?

@CJ_London
I think I'm going off topic because even if I remove mouse wheel function, screen is still flashing and flickering while moving through records. But since you suggested, I tested it.
I set the scrollbars in property sheet to Vertical, and used Me.Scrollbars=0 in On_Open event to hide it. Still without the function, mouse wheel doesn't scrolls through the form.
If you meant something else, I think I missed your point.
thanks for putting your time on this.

@arnelgp
I checked your version. I didn't know we can use conditional formatting in data sheet view of a form. Thanks for the lesson. Your code has some flaws (check the following image after selecting/deselecting several rows) but I know how to manage things. The idea is enough.
Anyhow we leave your solution as the last option (because of visual differences). thanks again.

2021-10-04_08-18-21.jpg
 

CJ_London

Super Moderator
Staff member
Local time
Today, 00:55
Joined
Feb 19, 2013
Messages
13,542
Is screen flashing normal in Access continuous forms?
No
or is it something wrong with this special form and its code?
yes - as explained, your mousewheel event is constantly changing the current record which is causing the flicker (Unhide your header controls and you will see what I mean)
 

CJ_London

Super Moderator
Staff member
Local time
Today, 00:55
Joined
Feb 19, 2013
Messages
13,542
Just found the code I referred to in post#9. It works with the mousemove event but not the mousewheel event so not relevant to you.
 

Sun_Force

Active member
Local time
Today, 09:55
Joined
Aug 29, 2020
Messages
350
No

yes - as explained, your mousewheel event is constantly changing the current record which is causing the flicker (Unhide your header controls and you will see what I mean)
@CJ_London
Sorry for acting stupid, but I really can't understand what you want to tell me. As I said even if I remove the on_mousewheel event, and delete the function at all, still moving through records with scroll bar flickers the screen. You can test it.

Would you please upload a version of the same file (with whatever changes you want to add) that doesn't flash the screen?

Again thanks
 

Users who are viewing this thread

Top Bottom