• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 852
  • Last Modified:

Access Form Flickers when using OnCurrent Event????

My OnCurrent Event seems to cause one of my continuous Access 2k form to flicker.  I will breifly explain below.  I'm using a basic method to highlight the selected row in a continuous form by using a control (TxtCurrentRecord) as the background with conditional formatting to change the color of this control to yellow when the value of this field = a hidden control called TxtID which has a control source of the unique product id. The displayed controls on the form are set to transparent and are overlayed directly over TxtCurrentRecord which is expanded to the width of all the displayed controls.

OnCurrent Event of the form ...  Me.TxtCurrentRecord = Me.TxtID

The conditional formatting basically sets the background & font colors of TxtCurrentRecord to Yellow where the field value = TxtID, thus highlighting the current record.  

This all works except in one form where the method is being used.  Each time I click a different record to make it the current the form basically flickers (kind of like a refresh or requery) but I'm not getting a Calculating ... in the status bar, just the flickering.  

I use this same method in several other forms and I don't get the flicker.  If I remove the displayed controls from on top of the TxtCurrentRecord control then the flicker stops but obviously I need the controls that control because that's what does the highlighting.

Any ideas will be appreciated ...

ET  
 
0
Eric Sherman
Asked:
Eric Sherman
  • 13
  • 6
  • 6
2 Solutions
 
puppydogbuddyCommented:
Hi ET,
I remember resolving a problem on EE a long time ago involving flickering. The problem in that case was caused by some kind of timing difference related to the execution and return from a called subroutine.  I was able to resolve the flickering problem in that case by turning screen painting off just before calling the subroutine, and then turning screen painting back on at completion of that code segment.  

I know your problem is different in some respects, but the remedy (sandwiching the code in the flicker interval using painting off and painting on) might work in your case.

HTH  
0
 
Eric ShermanAccountant/DeveloperAuthor Commented:
Thanks puppydogbuddy ...

I tried the following to no avail ...

Me.Painting = False
Me.TxtCurrentRecord = Me.TxtID
Me.Painting = True

It just seems strange that once I drag the displayed controls down below the TxtCurrentRecord control, it works.  I can move to another record and everything flows real smoothly.  The on current event will fire, I get a brief Calculating ... on the status bar with no flickering.  As soon as I move the displayed controls on top of the TxtCurrentRecord and try to move to another record seems like every record in the continuous form flickers.

ET
0
 
puppydogbuddyCommented:
ET,
I have used conditional formatting in a continuous subform with no problems. And you said you have other forms that have conditional formatting without flickering.  Maybe it is the way you specified the condition(s) for your conditional formatting that is causing a conflict with the formatting.  For example, expressions in the conditional formatting dialog (as best as I can remember) require that you use a fully qualified reference (e.g. Forms!frmx!.....) ; do not use the Me operator.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Eric ShermanAccountant/DeveloperAuthor Commented:
Yep PDB ....

Tried just about everything under the sun and as soon as the displayed fields are moved over the TxtCurrentRecord control to show the background as yellow, the on current event causes the records to flicker (when selecting another record).

ET
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
Two things can cause the screen to flicker:

1. Unassociated labels - make sure all your labels are associated with a control or convert them to text boxes.

2. Something in the OnCurrent that is causing it to be called repeatedly.  Put a stop there and see if it is being called repeadedly.

  If that bears no fruit, I can give you another method of coloring the row.

HTH
JimD.
0
 
Eric ShermanAccountant/DeveloperAuthor Commented:
Thanks for the reply JimD  ...  There's only one line of code in the OnCurrent Event.

Private Sub Form_Current()
Me.TxtCurrentRecord = Me.TxtID
End Sub

I also read several post regarding the Unassociated Labels issues and for testing purposes I removed all labels from the form.  I only have five Text Box fields on the form ....

TxtID  - Hidden and Control Source set to the unique Product ID in the table.

TxtCurrentRecord - This is the control that is set to the value of TxtID Using the OnCurrent Event and will be formatted to yellow using Conditional Formatting when the two fields holds the same value.

ProductID, ProductName, UnitPrice - These are the three detail fields that are displayed over the TxtCurrentRecord field.  They are set to Transparent so the yellow formatting is displayed.  

When I make a single detail row consisting of the TxtCurrentRecord control with the ProductID, ProductName and UnitPrice fields placed directly over the TxtCurrentRecord the OnCurrent Event seems to make all details flicker.

If I make two rows, one with just the TxtCurrentRecord field then place the ProductID, ProductName, UnitPrice directly beneath it then it works like it should.  Very smooth and no flicker when you navigate between records.

Yes, I would like to see your other method for coloring a row.

Thanks,

ET



0
 
puppydogbuddyCommented:
ET,
Just for kicks, try this code and see if it has any effect.

Me.Painting = False
DoEvents
Me.TxtCurrentRecord = Me.TxtID
Me.Painting = True
0
 
Eric ShermanAccountant/DeveloperAuthor Commented:
Thank PDB ...

Tried it along with a variation of DoCmd.Echo False/True to no avail.  In fact it seems like the more code in the OnCurrent Event the more pronounced the flicker becomes.  When I include the Painting False/True even the double row started to flicker when moving between records.

Interesting ....

ET
0
 
puppydogbuddyCommented:
This link sounds like your problem and solution.
                    http://www.moorlandit.net/index.php/2008/08/cant-uncheck-check-boxes-in-microsoft-access-2003-3
0
 
puppydogbuddyCommented:
It is a bug in conditional formatting.....see also this link:
                   http://allenbrowne.com/bug-05.html
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
<<Yes, I would like to see your other method for coloring a row.>>

attached.

JimD.
ContinuousFormColors.zip
0
 
Eric ShermanAccountant/DeveloperAuthor Commented:
Thanks PDB but unfortunately that's not the problem.  

1.) This is an Office 2000 application.

2.) I can remove the Conditional Formatting from the background TxtCurrentRecord control and the same flicker will happen when navigating between records as long as the ProductID, ProductName and UnitPrice fields are stacked directly over the TxtCurrentRecord field.

Seems like the problem I'm having is related to the fields being stacked over the TxtCurrentRecord which seems to be a bit confusing because it works in other forms.  As long as I place the displayed fields and the background field (TxtCurrentRecord) on two separate lines in the detail it works smoothly but this will not accomodate what I'm trying to accomplish.

ET

0
 
Eric ShermanAccountant/DeveloperAuthor Commented:
PDB and JimD ...

The attached file is a picture of the form I am testing with in Design mode. The field with the white background is TxtCurrentRecord.  As long as I place the fields in the detail section as shown in this picture, I can navigate between records without any flicker.  

When I move the 3 fields and stack them over the TxtCurrentRecord then try to navigate between records the flicker starts obviously after the OnCurrent Event fires.  I can disable the Conditional Formatting and the flickering will still continue when moving between records.  It has something to do with those fields being stacked over each other but I can't seem to figure out what.

ET




frmProducts.jpg
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
<< It has something to do with those fields being stacked over each other but I can't seem to figure out what.>>

 Do the three controls placed on top have their background mode set to transparent?

 and when moving them over txtCurrentRecord, try doing a "bring to front" on them to make sure they are on top in the z order.

JimD
0
 
Eric ShermanAccountant/DeveloperAuthor Commented:
JimD ....

Yes to both your questions.  The controls background is set to trnasparent and I have formatted them to "bring to front'.  

Just can't seem to find what else can be done to prevent that flickerng when the controls are stacked over each other, especially when it works in other forms.   I've checked all the properties on the form and nothing seems to be realted to this problem.

ET
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
Hum.. if you comment out:

Me.TxtCurrentRecord = Me.TxtID

 In the OnCurrent, does the flickering stop?

JimD.
0
 
Eric ShermanAccountant/DeveloperAuthor Commented:
JimD ...

Yes, if the OnCurrent does not fire (with the controls stacked over the TxtCurrentRecord) it works smoothly without any flickering while navigating between records.

ET
0
 
puppydogbuddyCommented:
ET,
Try this:

Me.TxtCurrentRecord = Me.TxtID
TxtCurrentRecord.SetFocus

0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:

  I'd also try setting the txtCurrentRecord enabled property to false so it can't receive the focus.

JimD.
0
 
Eric ShermanAccountant/DeveloperAuthor Commented:
PDB ....
Setting the Focus to the TxtCurrentRecord control basically brings that control to the front and you cannot see the other displayed controls.  Also, I still go the flickering.


JimD ...
I have it disabled and still got the flickering.  

I just looks kind of cheezy and I know I will get asked by several users why is it doing that because it can get a bit annoying if you have to navigate that form a lot.

ET
0
 
Eric ShermanAccountant/DeveloperAuthor Commented:
Ok, looking at the flickering it appears that I'm getting basically 2 flicks (probably one for the OnCurrent Event and one for the Conditional Formatting).  There's probably some way to adjust for it but I've exhausted all options including many of the comments posted here.

The flickering is annoying as you encounter 2 flicks each time you navigate to a new record.  I will probably leave the question open for a few more days but for now I will just disable the row highlighting on that form.  

ET
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
OK, one more thing I can think of trying along the lines of what PDB suggested:

Application.Echo False
Me.TxtCurrentRecord = Me.TxtID
Me.Repaint
Application.Echo True

JimD.
0
 
Eric ShermanAccountant/DeveloperAuthor Commented:
Thanks ... Tried it but still get the 2 flicks when moving to another record.  Kind of disappointing in a way because the customer wanted to have the option on that form.  I will look at your samples and see if I want to use those methods.  

I'm just trying to avoid having two methods for highlighting a row in the same application.

ET
0
 
Eric ShermanAccountant/DeveloperAuthor Commented:
Ok, I got it to work properly (without flickering when navigating between records) and I can confirm that it had something to do with that form (exactly what is the million dollar question).

Since the method I'm using to highlight the selected row works on other forms, I simply copied one of those forms and rebuilt the problem form there and it now works flawlessly without any flickering.

There was something up with that problem form but exactly what was never disclosed. I even noticed with the problem form, removing all VBA code from it and just opening it, the detail records will flicker 2 times.  

It works now and my problem is resolved.  I will split the point between PDB and JimD for their contributions.

Thanks,

ET  
0
 
Eric ShermanAccountant/DeveloperAuthor Commented:
Something was wrong with the form itself.  I used one of the forms that was working correctly and rebuilt the problem form.

Thanks for your input.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 13
  • 6
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now