Results 1 to 2 of 2
  1. #1
    kaledev is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    20

    Question Query in VBA error "between op without and"

    I may be missing something simple, perhaps a fresh pair of eyes will help. I have the following code running a query in VBA



    Code:
        Else
            strSQL = "SELECT [Q01 Generate Data with Duplicates].[Report Dt], [Q01 Generate Data with Duplicates].Controller, [Q01 Generate Data with Duplicates].Terminal, [Q01 Generate Data with Duplicates].[Eq Init], [Q01 Generate Data with Duplicates].[Equip Nr], [Q01 Generate Data with Duplicates].[Dwell Start Dt], [Q01 Generate Data with Duplicates].[Dwell Start Tm], [Q01 Generate Data with Duplicates].[Dwell Start Event], [Q01 Generate Data with Duplicates].[Dwell Days], [Q01 Generate Data with Duplicates].[Wb Origin], [Q01 Generate Data with Duplicates].[Wb Destination], [Q01 Generate Data with Duplicates].[Wb Route], IIf([outbound billing?] Or [inbound within freedays?],False,True) AS [CY Unit?], IIf((Not IsNull([Wb Origin])) And [Wb Origin]<>[dbo_OLDDATA]!Terminal And [Wb Destination]<>[dbo_OLDDATA]!Terminal,True,False) AS [Outbound Billing?], IIf([Dwell Days]<[Free Days] And [Dwell Start Event]='RMFC',True,False) AS [Inbound Within Freedays?]" _
            & "FROM [Q02 Allotment] INNER JOIN [Q01 Generate Data with Duplicates] ON [Q02 Allotment].TerminalName=[Q01 Generate Data with Duplicates].Terminal" _
            & "WHERE ((([Q01 Generate Data with Duplicates].[Report Dt]) Between CDate(#" & txtReportStartDate & "#) AND CDate(#" & txtReportEndDate & "#)))" _
            & "ORDER BY [Q01 Generate Data with Duplicates].[Report Dt], [Q01 Generate Data with Duplicates].Terminal;"
        End If
    When I run it, I recieve the following error:

    Run-time error '3075':

    Between operator without And in query experssion '[Q02 Allotment].TerminalName=[Q01 Generate Data with Duplicates].TerminalWHERE ((([Q01 Generate Data with Duplicates].[Report Dt]) Between CDate(#2/1/2011#'.

  2. #2
    kaledev is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    20
    nevermind, I didn't see that the WHERE clause was missing a space before it. face-palm on that one...

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

Similar Threads

  1. Replies: 13
    Last Post: 12-05-2011, 05:10 AM
  2. Replies: 2
    Last Post: 12-02-2010, 02:35 AM
  3. Replies: 11
    Last Post: 11-26-2010, 10:53 PM
  4. Replies: 8
    Last Post: 11-12-2010, 10:55 AM
  5. Replies: 0
    Last Post: 03-04-2010, 06: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