Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Append Query date problem (2003)

    Hi,

    I can't seem to get my SQL query right, I'm getting the message "expected 1". I am using Access 2003 and want a query that apeends data from one table to the other where the date is between a certain range. Heres what I've been playing with so far.

    strSQL = "INSERT INTO TblPath" & Split(Msg(i), " ")(1) & "Master SELECT " & DestTbl(i) & ".* FROM " & DestTbl(i)
    strSQL = strSQL & " WHERE ReceiveDate >= " & "01/09/2008" & " AND ReceieveDate <= " & "30/09/2008" & " ;"

    Originally I was using

    strSQL = "INSERT INTO TblPath" & Split(Msg(i), " ")(1) & "Master SELECT " & DestTbl(i) & ".* FROM " & DestTbl(i)
    strSQL = strSQL & " WHERE ReceiveDate Between " & "01/09/2008" & " AND" & "30/09/2008" & " ;"

    I have also tried putiting the dates in double quotes Between " & """" & "01/09/2008" & """" & " AND " & """" & "30/09/2008" & """" & ";"
    but this did not work either.

    Many thanks for your help
    Regards
    Gerbil (AKA Kevin)

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Append Query date problem (2003)

    What does your query look like in the immediate window?

  3. #3
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Append Query date problem (2003)

    INSERT INTO TblPathCellularMaster SELECT TblPathCellularSource.* FROM TblPathCellularSource WHERE TblPathCellularSource.ReceiveDate Between 01/09/2008 AND 30/09/2008 ;

    Thanks
    Regards
    Gerbil (AKA Kevin)

  4. #4
    4 Star Lounger SteveH's Avatar
    Join Date
    Jan 2001
    Location
    Chelsea, Gtr London, United Kingdom
    Posts
    587
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Append Query date problem (2003)

    Assuming that your dates are a date/time field, you need to wrap the dates with # signs.

    INSERT INTO TblPathCellularMaster SELECT TblPathCellularSource.* FROM TblPathCellularSource WHERE TblPathCellularSource.ReceiveDate Between #01/09/2008# AND #30/09/2008#;
    Steve H
    IT Lecturer/Access Developer
    O2K SR3/O2010; Win7Pro

  5. #5
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Append Query date problem (2003)

    Thank you
    Regards
    Gerbil (AKA Kevin)

Posting Permissions

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