Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228

    Show all "dates" when there is no deifned range

    Im using the following to narrow down user searches for information.



    Code:
    >=[Forms]![Timesheets]![TxtFrom] And <=[Forms]![Timesheets]![TxtTo]
    That's all well and good, but if these two text boxes are empty then I would like to "view all". Is there an easy way to do this?

    If its fairly complex I don't want to be spending a lot of time on it. I could just change the default value of the text boxes to something that includes all records. 7

    here is all the SQL for reference. as a note, I'm already filtering by a staff name selected via combo box.

    Code:
    SELECT PO_engineers.[PO Number], StaffT.Staff_Name, TimesheetData.Quantity_Hours, TimesheetData.Quantity_miles, TimesheetData.Quantity_Expenses, TimesheetData.Invoiced, TimesheetData.WeekEnding, StaffT.Staff_ID
    FROM (StaffT INNER JOIN PO_engineers ON StaffT.Staff_ID = PO_engineers.Engineer_ID) INNER JOIN TimesheetData ON PO_engineers.PO_ID = TimesheetData.PO_ID
    WHERE (((StaffT.Staff_Name)=[Forms]![Timesheets]![Combo22]) AND ((TimesheetData.Invoiced) Is Not Null) AND ((TimesheetData.WeekEnding)>=[Forms]![Timesheets]![TxtFrom] And (TimesheetData.WeekEnding)<=[Forms]![Timesheets]![TxtTo])) OR (((TimesheetData.Invoiced) Is Not Null) AND ((TimesheetData.WeekEnding)>=[Forms]![Timesheets]![TxtFrom] And (TimesheetData.WeekEnding)<=[Forms]![Timesheets]![TxtTo]) AND (([Forms]![Timesheets]![Combo22]) Is Null))
    ORDER BY TimesheetData.WeekEnding;

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Maybe use Nz function and use a far out date range?

    ((TimesheetData.WeekEnding)>= NZ([Forms]![Timesheets]![TxtFrom],#1/1/1900#) And (TimesheetData.WeekEnding)<= Nz([Forms]![Timesheets]![TxtTo],#1/1/2050#))

  3. #3
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Worked a treat. Didn't even think of this function.

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

Similar Threads

  1. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  2. Replies: 3
    Last Post: 02-16-2015, 01:04 PM
  3. Replies: 3
    Last Post: 12-06-2014, 03:59 AM
  4. Replies: 4
    Last Post: 02-13-2013, 02:35 PM
  5. Replies: 2
    Last Post: 11-14-2012, 04:47 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