Results 1 to 3 of 3
  1. #1
    NickWren is offline Advanced Beginner
    Windows XP Access 2013
    Join Date
    Dec 2015
    Location
    Connecticut
    Posts
    70

    Passing a Form Textbox to a query parameter

    So I have a Textbox called SearchParameters and two more called StartDate and EndDate on a form. I got the dates to work fine, using
    Code:
    Between Nz([Forms]![frmSampleStatus]![StartDate],#1/1/1900#) And Nz([Forms]![frmSampleStatus]![EndDate],#1/1/2200#)
    Now I want to find anything with those dates and null so in the or criteria I put Nz([Forms]![frmSampleStatus]![SearchParameters],Is Null). I even tried the SearchParameter by itself and all I get is #Name? all across the subform datasheet. Ive tried to make the textbox "Is Null", "Is Not Null", "Null", Null, and so on... I havent gotten anything to show both the dates I want and the ones that dont have dates.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    if you are using a form for the parameter, then it wont be null, so theres no need to put NZ in the query.
    If the FORM TEXT BOX is null , set the default there.

    but if you want to run with no dates, then you need 2 queries....
    if IsNull(txtStartDate) then
    docmd.openquery "qsQryNoDate"
    else
    docmd.openquery "qsQryDateRng"
    endif

  3. #3
    NickWren is offline Advanced Beginner
    Windows XP Access 2013
    Join Date
    Dec 2015
    Location
    Connecticut
    Posts
    70
    So There is no way to show last weeks tests (uses the completion date) that were completed and the ones still in progress (aka no date for completion).
    If I put Is Null in the query it will just always show those samples.

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

Similar Threads

  1. Passing parameter form value to a query result
    By OtakiriLad in forum Queries
    Replies: 3
    Last Post: 11-27-2015, 09:25 PM
  2. Replies: 5
    Last Post: 10-09-2015, 09:27 AM
  3. Passing parameter from form to query
    By rhubarb in forum Forms
    Replies: 3
    Last Post: 05-03-2015, 10:29 AM
  4. Passing textbox value into sql query parameter
    By gustavoavila in forum Access
    Replies: 7
    Last Post: 04-23-2014, 04:00 PM
  5. Query with parameter from Form Textbox
    By Juan4412 in forum Queries
    Replies: 1
    Last Post: 07-10-2013, 02: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