J
james
greetings. when i run this code and theTime falls in 2007 (ie. user
input is 1, 2, or 3) the program will delete the given number of days
only (not months).
Using msgbox, I've found that theTime is correct after the DateAdd
function, but deletion using SQL is wrong, very wrong. (I'm in
Australia so our date format is dd/mm/yyyy).
Dim userMonths As Integer
Dim nowTime As String
Dim theTime As String
Dim delTime As Date
'get user input on how many months in the past they wish to collect
records for
userMonths = InputBox("How many months do you wish to collect records
for? (1-48)", "SCIA Record Collector")
userMonths = userMonths * -1
'set the current time
nowTime = Now
theTime = DateAdd("m", userMonths, nowTime)
'delete records before the current time
DoCmd.RunSQL "DELETE * FROM POSITION WHERE ([PROCDATE] < " & "#" &
delTime & "#" & ")"
example of PROCDATE: 4/04/2007 9:41:26 AM
Cheers in advance!
James.
input is 1, 2, or 3) the program will delete the given number of days
only (not months).
Using msgbox, I've found that theTime is correct after the DateAdd
function, but deletion using SQL is wrong, very wrong. (I'm in
Australia so our date format is dd/mm/yyyy).
Dim userMonths As Integer
Dim nowTime As String
Dim theTime As String
Dim delTime As Date
'get user input on how many months in the past they wish to collect
records for
userMonths = InputBox("How many months do you wish to collect records
for? (1-48)", "SCIA Record Collector")
userMonths = userMonths * -1
'set the current time
nowTime = Now
theTime = DateAdd("m", userMonths, nowTime)
'delete records before the current time
DoCmd.RunSQL "DELETE * FROM POSITION WHERE ([PROCDATE] < " & "#" &
delTime & "#" & ")"
example of PROCDATE: 4/04/2007 9:41:26 AM
Cheers in advance!
James.