Results 1 to 5 of 5

Thread: Solved: move delete query from access query builder to code

  1. #1
    VBAX Mentor
    Joined
    Dec 2007
    Posts
    462
    Location

    Solved: move delete query from access query builder to code

    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
    [VBA]
    DoCmd.RunSQL "Delete IndividualSettingsTbl.Date" & _
    "From IndividualSettingsTbl" & _
    "WHERE IndividualSettingsTbl.Date < Date - 60;"
    [/VBA]

  2. #2
    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.

  3. #3
    VBAX Mentor
    Joined
    Dec 2007
    Posts
    462
    Location
    Ben Thanks, im stuck with the "Date" colume, this is kind of an after thaught, will try and let you know what happens

  4. #4
    Did Date() work? Rather than just saying -60 you might want to try DateAdd to give you exactly 2 months.

  5. #5
    VBAX Mentor
    Joined
    Dec 2007
    Posts
    462
    Location
    oh... I thaught I replyed to this a few days back but I guess I didn't , Yes it did work, Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •