Results 1 to 3 of 3

Thread: Slightly OT: Need help with a criteria expression (Access) [Resolveed]

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Resolved Slightly OT: Need help with a criteria expression (Access) [Resolveed]

    Hey,
    I am designing a query using Access query builder. The criteria of the query is 2 dates coming from 2 text boxes on a form inside the DB.

    this is the criteria that I have:
    Between [Forms]![Reports_Form]![startDate].[text] And [Forms]![Reports_Form]![endDate].[text]

    When I run this from the form the results are blank. Anyone know what I am doing wrong here?

    PS: Posted this in the Database section with little help, figured I would try here.

    Thanks
    Last edited by Besoup; Jul 6th, 2005 at 08:01 AM.

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: Slightly OT: Need help with a criteria expression (Access)

    I don't actually use the query builder, just the SQL view or buld it in code, but a couple possible things.
    Do your textboxes have values? This means the form has to be open. You can't just build the query and run it like you could if you referred to actual values.
    Second, and here I don't know about the query builder, are you querying correct data types? I'm guessing start_date & end_date are date fields in your table, but you're passing in strings from a textbox. You'd have to convert the strings to a date type, with # signs or CDate() - BETWEEN #Forms!Report_Forms...#. If you built your SQL in code, it would look something like this:
    VB Code:
    1. strSQL = "SELECT fldFoo FROM tblFoo WHERE fldDate BETWEEN #" & _
    2. [Forms]![Reports_Form]![startDate].[text] & "# AND #" & _
    3. [Forms]![Reports_Form]![endDate].[text] & "#"
    If for some reason the date fields are actually text data types, the example I gave would replace the # signs with single quotes. But since they wouldn't then be actual dates, looking BETWEEN them would be pretty futile. Maybe it would do some ascii or binary comparison, but even if so, probably not the results you want.
    Tengo mas preguntas que contestas

  3. #3
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Slightly OT: Need help with a criteria expression (Access)

    See your other thread in Databases Forum...

    [edit]
    Hmm Yeah forgot about the hashes, add those in too

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

Posting Permissions

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



Click Here to Expand Forum to Full Width