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
4 2997
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!
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: - 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. - Dim dteArchivedDate As Date
-
-
dteArchivedDate = GetSetting("Archive Date", "Date Archived", "Date")
-
-
If DateDiff("d", dteArchivedDate, Now()) >= 2 Then
-
'Open your Query
-
Else
-
MsgBox "Too early to run Query", vbExclamation, "Too Early"
-
End If
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
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 - Field; Type; IndexInfo
-
StudentID; AutoNumber; PK
-
Family; String; FK
-
Name; String
-
University; String; FK
-
Mark; Numeric
-
LastAttendance; Date/Time
Sign in to post your reply or Sign up for a free account.
Similar topics
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?
|
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...
|
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...
|
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...
|
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:
...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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)...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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....
|
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
| |