473,327 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Run query after a certain time has passed

Hi, im new here!
How can i run a query after a certain time has passed? I want to run a delete query to run 2 days after the data has been archived. I have created an append query which archives the data and records the date when it was archived.

Can any1 help me?

Thanks
Mar 24 '07 #1
4 2997
missinglinq
3,532 Expert 2GB
A strategy in very broad strokes:

Have a table with a date or date/time field in it, depending on how accurate you want to be.

When you run the Append Query to archive your data, write the date or date/time to this field.

In the Form_Load event of a form you generally run first thing on opening your db, compare the stored date or date/time with the current date or date/time.

If the difference is => 48 hours run the Delete Query

Reset the stored date to Null

An alternate method would be to have a form load but be invisible and use the Timer event of the form to do the above. Be aware, however, that the Timer running for extended periods can sometimes be problematical, sometimes causing screen flickering and other things!

Good Luck!
Mar 24 '07 #2
ADezii
8,834 Expert 8TB
Hi, im new here!
How can i run a query after a certain time has passed? I want to run a delete query to run 2 days after the data has been archived. I have created an append query which archives the data and records the date when it was archived.

Can any1 help me?

Thanks
As soon as your data is archived, write this Date to the System Registry:
Expand|Select|Wrap|Line Numbers
  1. SaveSetting "Archive Date", "Date Archived", "Date", Date
Prior to opening your Query, run this code to determine if it was at least 2 days since it was archived.
Expand|Select|Wrap|Line Numbers
  1. Dim dteArchivedDate As Date
  2.  
  3. dteArchivedDate = GetSetting("Archive Date", "Date Archived", "Date")
  4.  
  5. If DateDiff("d", dteArchivedDate, Now()) >= 2 Then
  6.   'Open your Query
  7. Else
  8.   MsgBox "Too early to run Query", vbExclamation, "Too Early"
  9. End If
Mar 24 '07 #3
A strategy in very broad strokes:

Have a table with a date or date/time field in it, depending on how accurate you want to be.

When you run the Append Query to archive your data, write the date or date/time to this field.

In the Form_Load event of a form you generally run first thing on opening your db, compare the stored date or date/time with the current date or date/time.

If the difference is => 48 hours run the Delete Query

Reset the stored date to Null

An alternate method would be to have a form load but be invisible and use the Timer event of the form to do the above. Be aware, however, that the Timer running for extended periods can sometimes be problematical, sometimes causing screen flickering and other things!

Good Luck!
How do i do it so that it compares the stored date and the current date. Do i use VB? if so what is the code?

Thanks
Mar 24 '07 #4
NeoPa
32,556 Expert Mod 16PB
We generally try to avoid doing the work for you in here. In short though, the current date is returned in the function Date(). If you want to post a stab at the SQL then we can help with that. Without table MetaData we couldn't give you much now anyway.
Here is an example of how to post table MetaData :
Table Name=tblStudent
Expand|Select|Wrap|Line Numbers
  1. Field; Type; IndexInfo
  2. StudentID; AutoNumber; PK
  3. Family; String; FK
  4. Name; String
  5. University; String; FK
  6. Mark; Numeric
  7. LastAttendance; Date/Time
Mar 27 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

20
by: | last post by:
If I need to check if a certain value does exist in a field, and return either "yes" or "not" which query would be the most effestive?
6
by: Martin Lacoste | last post by:
Ok, before I headbutt the computer... don't know why when I add criteria in a query, I get an 'invalid procedure call'. I also don't know why after searching the help in access, the various access...
7
by: Bernard Lebel | last post by:
Hello, I'm stumbled at a serious problem, and quite frankly getting desparate. This is a rather long-winded one so I'll try to get straight to the point. I have this Python program, that...
10
by: sesling | last post by:
I have created a query that will pull information from our database for the operators. This query will pull in on average 50,000 records. The operators need to refine the search results. I have...
8
by: Roland Hall | last post by:
In Access you use "*" + + "*", + can be replaced with & Calling a parameterized query in Access requires % be used in place of *, however, all that I have read show dynamic SQL passed to Access: ...
1
by: Starke | last post by:
I have a table where Im counting records that have a two certain criteria. My Question is, If one criteria is met, but the other isnt instead of not retrieving the record can the count value...
3
by: shorti | last post by:
db2 v 8.2 on AIX 5.3 I will try to explain as brief as I can what it is I need. I am building a function that will be called multiple times where I will need to return x amount of records each...
1
by: hmlarson | last post by:
I have a form/table with checkboxes that I would like the user to check / uncheck if they want a certain record to display in a gallery on a website. I'm having problems figuring out how to...
20
by: raylopez99 | last post by:
Inspired by Chapter 8 of Albahari's excellent C#3.0 in a Nutshell (this book is amazing, you must get it if you have to buy but one C# book) as well as Appendix A of Jon Skeet's book, I am going...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.