Results 1 to 6 of 6
  1. #1
    Ultimateneo is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    19

    Running update query o a specific date

    Hello,

    I was wondering if i can create an update query to run on a specific date.

    For example say i have prices that have increased this year and i want to run the update query to increase them by 2%.

    However, i want to update on a specific date i enter, so that users will only get the new prices on that date onwards.



    Is that possible to run the update query automatically or would i have to setup vba to this instead.

    Thank you for any help given.

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    Quote Originally Posted by Ultimateneo View Post
    Hello,

    For example say i have prices that have increased this year and i want to run the update query to increase them by 2%.

    However, i want to update on a specific date i enter, so that users will only get the new prices on that date onwards.
    If that is the case, you can add the records anytime before the prices go live, and your system takes into account when a new price takes effect.

    Then if you have to produce an invoice from a previous period and have not store the prices at that time, you will be able to locate the correct price for that period.?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Ultimateneo is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    19
    Hello Welshgasman,

    Thank you for your reply.

    Not sure you understood my question, of can i have the criteria of the update query make it run on a specific date to say update the prices by a percentage.

    For example, i get that this year the prices will go up by 2% on the 1st of April.

    I have this information a month beforehand, so rather than wait till 1st of April to run the query, i want to say on my form put in the date 1st of April and the percentage increase.

    The query should use these fields, the date to run the update on and the percentage increase or decrease to perform the update to the corresponding field in the table.

    Thank you for any help provided.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    Personally I think that is a little chancy, only because I have seen firsthand what can go wrong when something is not run when it should.
    Others might be able offer better advice on avoiding such a scenario.

    My thoughts were, you add new records with the price increased 2% and the effective date, and then when you look for the price of a product, you compare against the date it is being used.?

    So your prices table will have several records with dates and amounts. The dates showing when the price was in use, up to when the next price changes.?

    I suppose you could have a timer function, that ran every 24 hours or whatever period you wished to check, and if 1st April then run the query. However if the DB is not open, then that would not work.

    You could also use Task scheduler to run the query at the correct time, again that would only work if the computer was switched on.
    As 1st April is a Thursday this year, all those conditions will likely be true, but what if the 1st was a Sunday.?

    I'm not aware of criteria in a query, that will allow/stop it running, only outside processes that will decide if it should run the query?

    Personally if it was me, and I only had one price for each product in my Prices table, then I would go the Task scheduler route and make sure the computer was left on.

    Better wait until some others chip in with more knowledge of timing issues.?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    In situations similar to this, I often create a function to run the update query on or after the specified date and then set a value in a settings table to true.
    The function first checks if the value is true and, if so, exits.

    Next add a run code event to an autoexec macro to run the function. It can only run once due to the settings table value.
    The only remaining thing to do is to set that settings value false again at some future date.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    If your db is not opened on a regular basis but an application like Outlook is opened regularly then I'd use an Outlook task or meeting notice as a reminder to open the db and run the query. If you're doing regular (e.g. nightly) backups, that process should be able to be made time sensitive.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Update query running notifications
    By Esmatullaharifi in forum Queries
    Replies: 2
    Last Post: 04-07-2015, 07:34 AM
  2. Replies: 2
    Last Post: 06-26-2012, 10:31 AM
  3. Running an Update Query from a Macro
    By michaelb in forum Queries
    Replies: 7
    Last Post: 06-02-2011, 09:46 PM
  4. Running an update query
    By markod in forum Queries
    Replies: 3
    Last Post: 11-11-2010, 01:24 PM
  5. Help Automatically running and Update Query
    By JohnRandolphSTL in forum Queries
    Replies: 8
    Last Post: 04-13-2010, 02:08 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums