Results 1 to 4 of 4
  1. #1
    BorisGomel is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    Apr 2011
    Posts
    101

    Run Query by dates

    Hi all of you.
    Just a small problem that bothers me . I created the code below to run query based on two dates -beginning and end , but the query doesn't work and it isbugging a mistake 13 -no matching variance.I was able to do it in the report and I am trying to do it in query so that a user types two dates and query shows all records within these two dates .


    Dim Criteria As String
    If IsDate([qdate]) And IsDate([qdate1]) Then


    Criteria = "[DateQB]>=# " & _
    [qdate] & " # and [DateQB]<= #" _
    & [qdate1] & " # "
    DoCmd.OpenQuery "ChecksPrinted2011QB", acNormal, Criteria
    End If

    Thank you in advance for help.

    The Best Regards,

    BorisGomel

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    OpenQuery doesn't have a criteria argument like that (you have that in the position of the data mode argument). OpenForm and OpenReport both have a wherecondition argument, where your criteria should work. Info here:

    BaldyWeb wherecondition
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    BorisGomel is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    Apr 2011
    Posts
    101

    Run Query by dates

    Thank pbaldy,

    The code works in the report.

    Thank you again,

    Best Regards.

    BorisGomel

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    No problemo.
    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. Problems with Dates in a query
    By oldteddybear in forum Access
    Replies: 3
    Last Post: 01-14-2011, 10:36 AM
  2. Mixed dates - show only complete dates?
    By weeblesue in forum Queries
    Replies: 3
    Last Post: 10-27-2010, 02:15 PM
  3. Dates: query and criteria
    By isnpms in forum Queries
    Replies: 5
    Last Post: 08-22-2010, 08:01 AM
  4. Between dates query question
    By ostroms1 in forum Queries
    Replies: 3
    Last Post: 07-23-2010, 05:04 PM
  5. Matching Query Dates
    By rgwynne in forum Queries
    Replies: 1
    Last Post: 08-13-2009, 05:23 AM

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