Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2003
    Posts
    228

    Unanswered: Problem with OpenReport WHERE X Between Y and Z

    I have a macro that uses the OpenReport "Action" to open report A. It has the where condition as
    [Date Closed] Between [Enter beginning Date] And [Enter Ending Date]

    When I move this to VB Code so it can be more flexible, I get the Compile Error "expecting: =".

    It's like the compiler will only accept a WHERE clause with an "=" and not the between operator....

    Any help out there?

  2. #2
    Join Date
    Oct 2003
    Location
    Boston, MA
    Posts
    15

    Re: Problem with OpenReport WHERE X Between Y and Z

    Originally posted by ottomatic
    I have a macro that uses the OpenReport "Action" to open report A. It has the where condition as
    [Date Closed] Between [Enter beginning Date] And [Enter Ending Date]

    When I move this to VB Code so it can be more flexible, I get the Compile Error "expecting: =".

    It's like the compiler will only accept a WHERE clause with an "=" and not the between operator....

    Any help out there?
    SELECT foo, bar FROM MyTable WHERE mytable.[date closed] > [enter beginning date] AND < [enter ending date]

  3. #3
    Join Date
    Jul 2003
    Posts
    25
    I'm not sure what code you are using but I have similar code set up for a query that tracks and reports rail car events. Here's my code which seems to work just fine:

    DoCmd.OpenReport "RailTracking Query", acViewPreview, "", "[RailTracking Query]![ReleaseDate] Between [RailTracking Query]![NeedByDate] And [RailTracking Query]![DOA]", acNormal

    This looks for release dates on my CP cars which are between the NeedByDate and DOA(Date of Arrival). I hope this helps. If not, I probably didn't understand the question.

  4. #4
    Join Date
    Sep 2003
    Posts
    228
    I was putting the arguments to openreport in parenthesis and that was causing a problem. oops

Posting Permissions

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