Hoping to use Form_AfterRender or Form_AfterFinalRender, but No Joy...

Papa_Bear1

Member
Local time
Today, 12:15
Joined
Feb 28, 2020
Messages
86
Maybe I don't understand what these routines are for, but, I cannot get them to fire - at all.

My intention is to use the Detail_Paint routine to do a little custom formatting, but this routine is called over and over again.
So, I want to find a way to trap if/when the form is *first* rendered, and then only run this custom formatting that first time around.
So, I've tried setting a Boolean to False when the form is loaded, and then setting that Boolean to True once the form is 'rendered'. But again, I cannot get these routines to fire, so I can't control the custom formatting code (which gets VERY confused, btw, when you start mousing-over and clicking in the form. Ha.)

How/when do these render events fire? I cannot get them to fire.
 
I have never needed any report event except ON PRINT.
this worked for everything.
 
Why does your code have to respond to the paint event of Form?
Why can't the code be triggerd by Load event?
 
I THINK, the Render family are for charts and other Draw objects and not for the actual events on a report.
 
Last edited:
So - I'm listing some items on the form (not a report... I've done this with reports and it is not as troublesome as they are essentially not dynamic.)

I would like certain repeated fields to not show - like not repeating the parent unnecessarily. I intend to simply paint the font white. This has worked on reports just fine. On forms, however, when you do anything that makes it repaint - then the logic that typically works on a report, or when a form is first loading - no longer works because it is difficult to say where they are clicking and what the 'last' item was etc.

So, the 'render' types of routines seemed like candidates for checking if/when Access is 'done' drawing the form, but - apparently not. (I'll take a look at that reference... :) )
 
Why does your code have to respond to the paint event of Form?
Why can't the code be triggerd by Load event?
The only reason it needs to be in the paint event is that the formatting is to be changed line-by-line.
 
I just don't understand why an event is listed, but then ignored. Why do they even list it as being available for a form - but - not really. It's a red herring... Ha...
 
I was thinking maybe there would be a way for me to discern when it had 'painted' the last item, and use that as my trigger for flipping the Boolean that I'd later use to ignore any mouse movements and clicks etc. as far as the formatting. Not sure if there is a way to discern when it is done painting though.

Thanks for all your thoughts/feedback!
 
If you do not need to be able to change any data in the subform, you could use a report instead of the subform.

Otherwise:
Have you ever tried setting the font color with conditional formatting?
 
If you do not need to be able to change any data in the subform, you could use a report instead of the subform.

Otherwise:
Have you ever tried setting the font color with conditional formatting?
Right - well - I'm doing this on a form because I do intend to support activities/operations etc., so data will change, and thus a Report will not do.

I'm trying to mimic some formatting that I've done on Reports, but on a Form.

I considered Conditional Formatting, but the only way a choice can be made on the formatting in this case, is to keep track of the 'previous' parent entity, and check if the currently painted row has the same value, and if so, set the format (white font). I'm not sure there is a way to 'instruct' the conditional formatting to consider this situation. It tends to expect the formatting to based on the current value (alone) - which is quite understandable - just not what I happen to need.
 
No idea if it would work in your circumstances but one hack I've used to get something to happen as the last possible event after a form has loaded and rendered is to stick it on a half second timer.
 
Maybe I don't understand what these routines are for, but, I cannot get them to fire - at all.

My intention is to use the Detail_Paint routine to do a little custom formatting, but this routine is called over and over again.
So, I want to find a way to trap if/when the form is *first* rendered, and then only run this custom formatting that first time around.
So, I've tried setting a Boolean to False when the form is loaded, and then setting that Boolean to True once the form is 'rendered'. But again, I cannot get these routines to fire, so I can't control the custom formatting code (which gets VERY confused, btw, when you start mousing-over and clicking in the form. Ha.)

How/when do these render events fire? I cannot get them to fire.
The *Render events are related to Pivot Charts (as it says in the doc you attached), and those have been deprecated.
 
Use the recordsource to ‘hide’ values- see this link for various ideas

 
It sounds to me like your tables are not normalized. If they were, you wouldn't have repeating data. Forms should never hide data except perhaps for security reasons like normally keeping the SSN hidden but only unhiding it if you specifically need to see it or enter it.
 
Have a look at the detail paint event, it can act like conditional formatting but without the inherent "slowness".
You can use it set a back colour of a control based have a look at Colins Colour picker.

 
My intention is to use the Detail_Paint routine to do a little custom formatting, but this routine is called over and over again.
So, I want to find a way to trap if/when the form is *first* rendered, and then only run this custom formatting that first time around.
Completely un tried but maybe you could turn off the event handler after the last record is painted.
in the on paint event remove "[event procedure]" from the event handler after the last record is painted the first time.
C:
if me.recordset.absoluteposition = me.recordset.recordcount - 1 then
  me.detail.onpaint = ""
end if

Worth a try, but unlikely to give the results you need.
 
I tested my suggestion and it will probably not work.
Although you can "turn off" the event procedure you cannot stop access from actually doing the event. So it will continue to paint, just your code in the event handler will not execute. This means when it does repaint it will likely update that row/s to the last color applied in the on paint procedure. Also I thought that the onpaint event happens once per record, that is not the case. It is multiple times.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom