Results 1 to 9 of 9
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    function valid only once (Access 2000)

    In the OnOpen event of the form i have a function callled collect that i want to perform only once,
    and after that to be invalid or not working.Is it possible with Access ?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: function valid only once (Access 2000)

    Do you mean that you want to execute the function only the first time the form is opened, and never after that? If so, do you use the function only in this form, or also in other forms?

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,430
    Thanks
    1
    Thanked 33 Times in 33 Posts

    Re: function valid only once (Access 2000)

    I'm not exactly sure your intent here, but it sounds like you need to set a registry entry to control whether or not the function is to be run. I'd probably put all the registry checking in the function itself. the first thing the function would do is check to see if it was run before. If it was, then just exit the function. if it wasn't, make the Registry entry then finish running the function normally.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: function valid only once (Access 2000)

    Yes, exactly that.I want to execute the function only the first time the form is opened , and never after that.I use the function only in this form.This form is
    central to my database. The database is in a zipped condition and each morning we collect the information afresh and only once.I am afraid it is not possibl to make the function invalid in the OnOpen event, but i am asking just in case someone may know some trick to do it.

    regards

  5. #5
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,613
    Thanks
    3
    Thanked 58 Times in 58 Posts

    Re: function valid only once (Access 2000)

    Have you considered a small configuration table in the database that contains the date the event was last run? Then when the form opens, if that date is the current date, you don't run the code, but if it is you run the code and update the date in the configuration table to the current date.
    Wendell

  6. #6
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: function valid only once (Access 2000)

    I would prefer a Yes/No field rather than a Date field, since they could open the form more than once on the first day.

  7. #7
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,613
    Thanks
    3
    Thanked 58 Times in 58 Posts

    Re: function valid only once (Access 2000)

    If I understand the process correctly, they want the process to run once and only once the first time they open the database on any given day. Using a Yes/No field doesn't allow that.
    Wendell

  8. #8
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,430
    Thanks
    1
    Thanked 33 Times in 33 Posts

    Re: function valid only once (Access 2000)

    If this function is run once a day by every user, then I'd use the Registry entry approach. The registry entry would be the date the function was last run. If it is equal to today's date, then don't run it.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  9. #9
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: function valid only once (Access 2000)

    I didn't realise that this was to happen once per day. In that case you are absolutely right.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •