Results 1 to 5 of 5
  1. #1
    bbxrider is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Posts
    69

    passing a date from a form to a query

    in the criteria field of a date column I am trying to pass values entered on a form
    Between #forms![percent_rpt_form]![percent_start_date]# And #Forms![percent_rpt_form]![percent_end_date]#
    when trying to save the query I get:


    "the expression you entered has an invalid date value."
    I have tried ...date.text, ...date.value, ....date].text, ....date].value
    but can't seem to make access happy

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,746
    Is the Form open? try without the # signs.
    Can you post the SQL of the query you are using?

  3. #3
    bbxrider is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Posts
    69
    thanks, this is as close to sql as I can send, it does not allow the between statement with the #(date) brackets after it is entered in the criteria field either to save or to view in sql
    SELECT transaction_history.Detail, transaction_history.comm_id, transaction_history.Tier, transaction_history.eType, transaction_history.[trans-date]
    FROM transaction_history
    WHERE (((transaction_history.[trans-date]) Between [forms]![partic_percent_rpt_form]![partic_percent_start_date] And [Forms]![partic_percent_rpt_form]![partic_percent_end_date]));
    when I run this version without the # brackets the query runs but gives results not within the date range supplied, it accepts all records in the source table, with no date range criteria applied
    I used the access build editor to provision the text box fields, i.e. I did not type the values in myself

  4. #4
    bbxrider is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Posts
    69
    the query works if I hard code dates within the # date brackets in the between statement

  5. #5
    bbxrider is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Posts
    69
    ok got 1 solution anyway. I am casting the date from the form with cdate. once that is done you can do a direct compare either with 'between' or using operators, <= and >=, and no # date brackets are needed. note that the source field from the table being compared is defined as date time in the table. so far the # date brackets work with hard coded text values, eg. #11/1/14# but not sure why the # brackets can't seem to work with a variable like text box content from a form

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

Similar Threads

  1. Replies: 1
    Last Post: 12-05-2014, 01:06 PM
  2. Passing A Date Range From Form To Report
    By JeffGeorge in forum Reports
    Replies: 3
    Last Post: 03-11-2014, 12:50 PM
  3. Passing Form Field Value to Query
    By calgarianguy in forum Forms
    Replies: 1
    Last Post: 06-11-2013, 09:35 PM
  4. passing values from form to query
    By gregd in forum Access
    Replies: 6
    Last Post: 05-02-2013, 03:18 PM
  5. Passing Form Variable to Query
    By allenrickson in forum Reports
    Replies: 10
    Last Post: 06-27-2011, 07:33 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