Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004
    Posts
    7

    Unanswered: null value when ran in form but gets proper value manually

    "SELECT Sum(banked_entitlement_hist.banked_original_entitl ement) AS SumOfbanked_original_entitlement1 FROM employee INNER JOIN banked_entitlement_hist ON employee.ID = banked_entitlement_hist.employee_past_id WHERE banked_entitlement_hist.date_added Between " & txt_first_date & " And " & txt_second_date & ""

    I'm wondering why I can get the value I want in the QBE grid (SQL view) when I run this query but when I attach it to a form I get a null value:

    str_sql_1 = "SELECT Sum(banked_entitlement_hist.banked_original_entitl ement) AS SumOfbanked_original_entitlement1 FROM employee INNER JOIN banked_entitlement_hist ON employee.ID = banked_entitlement_hist.employee_past_id WHERE banked_entitlement_hist.date_added Between " & txt_first_date & " And " & txt_second_date & ""

    Set rs_bank_entitle = db.OpenRecordset(str_sql_1)

    txt_bank_total_entitlement.SetFocus
    txt_bank_total_entitlement.Text = rs_bank_entitle![SumOfbanked_original_entitlement1] & ""

    Any help greatly appreciated, thanks

    Troy.

  2. #2
    Join Date
    Feb 2004
    Posts
    142
    Try
    Between #" & txt_first_date & "# And #" & txt_second_date & "#"

    Note the addition of #s

    In the query you were most likely prompted for the values of first and second date. the # is how to define a date in SQL.
    KC

  3. #3
    Join Date
    Jan 2004
    Posts
    7

    running query manualy versus behind a form

    Originally posted by AZ KC
    Try
    Between #" & txt_first_date & "# And #" & txt_second_date & "#"

    Note the addition of #s

    In the query you were most likely prompted for the values of first and second date. the # is how to define a date in SQL.
    thanks az kc worked well!!!

Posting Permissions

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