I just don't get it!!!

A real begineer

Registered User.
Local time
Today, 08:47
Joined
Nov 4, 2000
Messages
74
I have written an application over the last twelve months in Access 2000. Originally as a query, and more recently as VBA. This has been a long, torturous and tedious path, however, I am now complete. Except for one function, which I have had trouble with since day one.

The delete recordset stuff, I just don't get it. All I am trying to do is ask the button to delete all records from my database prior to a date 4 days past. So far all I have been able to acheive is deleting the entire table, or generating object errors. Obviously I am missing something in my really simple understanding of VBA, maybe someone out there can clear the cobwebs for me.
 
What you need to do is build a delete query and in the criteria row for the date field enter <Date()-4. This should delete the appropriate records. before you do that though run the query in normal select query mode to check you're selecting the right records.

On the command button for running the query enter
Docmd.setwarnings false
Docmd.OpenQuery "<QueryName>"
Docmd.setwarnings true

This will run the query.(The setwarnings statement prevents warning messages appearing such as "You are about to delete X records..."

That should do it.
 

Users who are viewing this thread

Back
Top Bottom