473,779 Members | 2,063 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Run query after a certain time has passed

2 New Member
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 3016
missinglinq
3,532 Recognized Expert Specialist
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 Recognized Expert Expert
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
ramdayal9
2 New Member
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,577 Recognized Expert Moderator MVP
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
10163
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
29942
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 newsgroups, the access support centre, I can seem to find no similar situation. I am not using any references, or VBA at all in the first place. I am trying to set up a simple (or so I thought) query to work with the text of two tables. ...
7
3537
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 performs MySQL queries to a database. These queries are performed at regular intervals. Basically it is looking for fields that match certain criterias. Such fields are not present at all time. When the program finds such field, it then takes
10
6230
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 used the following in the criteria section of the query for the operators to refine the search . However, the operators do not always remember how the clients name appears in the DB and we get several failed queries. To correct this, I created a form...
8
8053
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: WHERE LIKE '" & ASPvar & "' % ORDER BY ... However, my call is similar to: conn.qMyLookup strVar, rs
1
2205
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 return "0"? Ie My query is as below. Employee ID --->no criteria to meet Shift = B Pass = True (its a check box)
3
1933
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 time for the same basic query. I will be basically get passed in where I had left off the last call but it is two fields that make up this unique index. The main rule is that I cannot hold open a cursor on the record I last read because it...
1
3209
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 construct the update query so that it picks up when a user checks/unchecks the checkbox and updates the db w/ the matching record ID#. Right now, if a user unchecks a box, the value does not get passed and the DB does not update - set/change it to...
20
2910
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 through some LINQ queries. But how to cast? ( See the below, modified from somebody else's code. The problem is the query 'stops' (throws a cast exception) at "3", and never gets to "violet".
0
9636
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10306
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8961
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.