|
-
Feb 12th, 2001, 09:48 AM
#1
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?
-
Feb 12th, 2001, 03:38 PM
#2
Member
If you run this program daily, perform this query in the Load event for your main form:
Code:
DELETE [Table1].*
FROM [Table1]
WHERE (((Date())>[Table1].[DateField]+10));
Where [Table1] is your table and [DateField] is the field you judge the age by.
If you don't run it daily - I'm not sure.
Boring signature included.
VB6 SP3.
-
Feb 13th, 2001, 02:49 AM
#3
Thanx but...
...VB complains about the asterisk (*) after the Delete line and the ";" after the Where line.
I made it like this:
Code:
Delete grdDataGrid.*
From grdDataGrid
Where (((Date) > grdDataGrid.Columns(0) + 10));
But it complains on this and that...
Because i made this program from an wizard, i might got it all wrong with the values.
-
Feb 14th, 2001, 10:08 AM
#4
Anyone??
-
Feb 14th, 2001, 03:26 PM
#5
Member
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)
Boring signature included.
VB6 SP3.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|