Hi!
I have an VB6 project that uses an MS Access97 database.
I want to autodelete posts that are older than 10 days. I have a date column in my DB.
How do I do?
Can I make it in VB or in Access or in both?? The easiest way?
Printable View
Hi!
I have an VB6 project that uses an MS Access97 database.
I want to autodelete posts that are older than 10 days. I have a date column in my DB.
How do I do?
Can I make it in VB or in Access or in both?? The easiest way?
If you run this program daily, perform this query in the Load event for your main form:
Where [Table1] is your table and [DateField] is the field you judge the age by.Code:DELETE [Table1].*
FROM [Table1]
WHERE (((Date())>[Table1].[DateField]+10));
If you don't run it daily - I'm not sure.
...VB complains about the asterisk (*) after the Delete line and the ";" after the Where line.
I made it like this:
But it complains on this and that...Code:Delete grdDataGrid.*
From grdDataGrid
Where (((Date) > grdDataGrid.Columns(0) + 10));
Because i made this program from an wizard, i might got it all wrong with the values.
Anyone??
Sorry,
This is an SQL Query.
You will need to set up a string and use it as the basis for a recordset using ADO - if you don't know how, there are tons of threads on this site that you can search for to find out (that's how I learned and I'm still not very good):
Code:
Dim adoDataCn As ADODb.Connection
Dim adoDataRs As ADODb.Recordset
Dim strDataCn As String
Dim strSQL As String
' Set up connection etc here - if you don't know how, search this site for connection string and you'll be able to work it out - that's how I learnt.
' then set up SQL string
strSQL = "DELETE [Table1].* " & _
"FROM [Table1] " & _
"WHERE (((Date())>[Table1].[DateField]+10));"
' and execute the deletion
Set adoDataRs = adoDataCn.Execute(strSQL, , adCmdText)