Results 1 to 7 of 7
  1. #1
    Cyborg is offline Novice
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    3

    BETWEEN in a FROM Statement

    Hello,



    I'm having trouble using BETWEEN in a FROM statement. The query is pretty simple and any help would be greatly appreciated.

    This is a .accdb Access 2007 db
    Error message I get: Between operator without And in query expression tblOrders.DeliveryDate BETWEEN tblFiscalCalendar.WeekStart

    SELECT tblFiscalCalendar.FiscalYear, tblFiscalCalendar.Period, Sum([tblInvoiceLines]![PricePerUnit]*[tblInvoiceLines]![QuantityShipped]) AS Sales INTO SalesByFiscalPeriod

    FROM tblFiscalCalendar INNER JOIN (tblOrders INNER JOIN tblInvoiceLines ON (tblOrders.DeliveryDate = tblInvoiceLines.DeliveryDate) AND (tblOrders.OrderNumber = tblInvoiceLines.OrderNumber)) ON tblOrders.DeliveryDate BETWEEN tblFiscalCalendar.WeekStart AND tblFiscalCalendar.WeekEnd

    WHERE (((tblOrders.ChainCode)="WNE") AND (([tblFiscalCalendar].[FiscalYear])=2009 Or ([tblFiscalCalendar].[FiscalYear])=2010 Or ([tblFiscalCalendar].[FiscalYear])=2011))

    GROUP BY tblFiscalCalendar.FiscalYear, tblFiscalCalendar.Period;

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    did you create this with the qry wizard?

  3. #3
    Cyborg is offline Novice
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    3
    Quote Originally Posted by ajetrumpet View Post
    did you create this with the qry wizard?
    No. I started in design view but edited the sql to try to get that join to work. Doesn't appear to be possible using the ui but i'm no expert

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    never written something like this. But I'm guessing it's not going to happen. sorry!

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'm not sure you can use Between in the join. You can use >= & <=
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Cyborg is offline Novice
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    3
    Thanks pbaldy! That totally just worked. Didn't think to do that.
    I know i've seen between used in T-SQL

    Much appreciated!!!

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problem, and welcome to the site!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Help with IF statement
    By mkallover in forum Programming
    Replies: 7
    Last Post: 01-04-2011, 04:47 PM
  2. Need Help with SQL Statement
    By Hank44 in forum Programming
    Replies: 3
    Last Post: 11-08-2010, 05:49 PM
  3. Help with Iif statement
    By tmcrouse in forum Queries
    Replies: 2
    Last Post: 09-02-2010, 09:00 AM
  4. IIf Statement...HELP!
    By bdhFS in forum Queries
    Replies: 5
    Last Post: 05-19-2010, 07:55 AM
  5. how to use IF then statement
    By ronnie4 in forum Access
    Replies: 1
    Last Post: 03-17-2009, 11:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums