PDA

View Full Version : Solved: move delete query from access query builder to code



Trevor
04-12-2008, 09:41 PM
I am trying to transfer my delete query from access query builder to VBA to hardcode it and am having problems , I think the compiler isn't happy with "Date < Date -60" but not sure how to make the compiler happy on this one, I have even tried declering date as a string stdate and that didn't seem to help

DoCmd.RunSQL "Delete IndividualSettingsTbl.Date" & _
"From IndividualSettingsTbl" & _
"WHERE IndividualSettingsTbl.Date < Date - 60;"

ben.oates
04-14-2008, 06:22 AM
Date is a bad column name to use. If you're after the actual Date() function you need brackets, but if you're after your column name you need [Date] square brackets. Also, you're missing a space before From and Where.

Trevor
04-14-2008, 08:11 AM
Ben Thanks, im stuck with the "Date" colume, this is kind of an after thaught, will try and let you know what happens

ben.oates
04-18-2008, 06:55 AM
Did Date() work? Rather than just saying -60 you might want to try DateAdd (http://www.databasedev.co.uk/dateadd_calculation.html) to give you exactly 2 months.

Trevor
04-18-2008, 04:33 PM
oh... I thaught I replyed to this a few days back but I guess I didn't , Yes it did work, Thanks