Preventing OnCurrent event of subform to fire muliple times RRS feed

  • Question

  • I have some code to highlight the current/selected row in a continuous form to make it easier for the users to read the data.

    To achieve this, I have a hidden textbox which keeps the ID of the current record. This textbox is updated every time another record is selected (I use the On Current event of course). Using conditional formatting (background textboxes and comboboxes) I can "highlight" the current/selected record. This is a workaround many other developers use.

    When opening the continuous form as a "main form", there is no real problem. The screen seems to flicker only once but still opens smoothly. The problem is that the form seems to flicker a lot when the continuous form is opened as a subform. I already reduced the number of times the "OnCurrent" event of the "subform" (thus: continuous form) is executed by checking if the "Load" event of the main form has been completed/finished (using a public variable). When the "Load" event of the main form has not been completely executed, all events of the subform are stopped (GoTo Exit_Sub). Furthermore, I also added code to programmatically set the recordsource of the "subform" instead of using the parent/child settings in combination with a fixed recordsource. Finally, I also added code to check if the continuous form is opened as a "main" or "sub" form. Everything works great although I can't seem to find a way to prevent the "OnCurrent" event of the "subform" to fire only once and thus getting rid of the unnecessary flickering.

    I do have to find a decent solution though since my latest customer (a very important customer) really keeps asking me if I can find a way to avoid the excessive flickering. I really hope someone can help me.

    Tuesday, November 13, 2018 4:59 PM

All replies

  • Hi,

    I am not sure why you're using code to track the current ID, isn't it always available anyway by simply referring to the form or subform? In any case, have you tried setting Echo Off (maybe)?

    Just a thought...

    Tuesday, November 13, 2018 5:26 PM
  • Can you provide a sample database that demonstrates this problem?  I built a very simple example of my own, using what I gather is your approach, but I don't get any flicker.

    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html

    Tuesday, November 13, 2018 10:06 PM