locked
detect Form or Report open RRS feed

  • Question

  • from a module is one able to detect a form/report open event - and harvest the object name?

    am needing to log opens with a time stamp - and can put in each object's Open Event - but that means visiting every object, and so am wondering if it is detectable as a global...

    I am aware of collections tables a little bit - have looked at some online info but never have had a need to use them....so not sure if the idea is feasible....  TIA

    Tuesday, March 3, 2020 11:30 PM

Answers

All replies

  • You can certainly write centrally managed code that applies to all forms, but it DOES require you to add a few lines to each form's code-behind. You could automate that process if you wanted to.

    See also: https://www.wisdomjobs.com/e-university/ms-access-tutorial-203/withevents-processing-8546.html


    -Tom. Microsoft Access MVP

    Tuesday, March 3, 2020 11:41 PM
  • thanks TvS… just wasn't sure if I have to put a little code at each object - looks I do....  

    Tuesday, March 3, 2020 11:44 PM
  • If you decide to write code to add code: see Module.InsertLines in the help file. It's not trivial, and somewhat time consuming, but more fun than copy/paste.

    -Tom. Microsoft Access MVP

    Tuesday, March 3, 2020 11:50 PM
  • just wasn't sure if I have to put a little code at each object - looks I do....  

    Hi msdn…,

    As a one-time-action you can place one line in each form's Open event:   On_Open_event Me.

    In a general module you place the procedure:   Sub On_Open_event (cur_form As Form)

    From now on you can modify the sub On_Open_event to have the modifications available in all forms.

    The same holds for reports, or whatever object you want to tune.

    Imb.



    • Edited by Imb-hb Wednesday, March 4, 2020 7:26 AM
    Wednesday, March 4, 2020 7:26 AM