Results 1 to 3 of 3
  1. #1
    pratim09 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Apr 2011
    Posts
    30

    Query for non mandatory fields

    I have a form which returns data based on few fields in a subform by requery.That is working fine if all my search critirea values are given.The record source of the subform is a query which returns data .Now my prob is I want say out of 5 fields sometimes 3 are given then also it wil serach according to 3 criteria and if all are given then it it will search with all criteria.Below is my query with all field giving value .

    SELECT TBL_HOURS_TRACKING.TrackingId, TBL_HOURS_TRACKING.ReleaseName, TBL_HOURS_TRACKING.ProjectName, TBL_HOURS_TRACKING.WorkIdentifier, TBL_HOURS_TRACKING.DefectNo, TBL_HOURS_TRACKING.HDTNo, TBL_HOURS_TRACKING.TestType, TBL_HOURS_TRACKING.Name, TBL_HOURS_TRACKING.ActualMonth, TBL_HOURS_TRACKING.WorkItem, TBL_HOURS_TRACKING.Hours, TBL_HOURS_TRACKING.Comments
    FROM TBL_HOURS_TRACKING
    WHERE (((TBL_HOURS_TRACKING.ProjectName)=[Forms]![frmHoursTrackingModify]![cmbProjectName]) AND ((TBL_HOURS_TRACKING.WorkIdentifier)=[Forms]![frmHoursTrackingModify]![WorkId]) AND ((TBL_HOURS_TRACKING.Name)=[Forms]![frmHoursTrackingModify]![txtName]) AND ((TBL_HOURS_TRACKING.ActualMonth) Between [Forms]![frmHoursTrackingModify]![txtStartDate] And [Forms]![frmHoursTrackingModify]![txtEndDate]));



    How do I make say date and porject name in the form non mandatory in the query

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Have you tried setting filter options for optional fields and turning the filter on/off as you need it?

    for instance

    dim sFilter as string

    if not isnull(field1) then
    sFilter = "[FieldName] = '" & me.Field1 & "'"
    (text field example)
    else
    sFilter = ""
    Endif

    me.filter = sfilter
    me.filteron = true

    I'm not

  3. #3
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    <snip>How do I make say date and porject name in the form non mandatory in the query
    This might help with the project name....

    http://access.mvps.org/access/queries/qry0001.htm

    For the dates, you might have to default the start date control to something like "01/01/1902" and the end date control to "12/31/2050".

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

Similar Threads

  1. Save as Draft but mandatory field is not required
    By zuerin in forum Programming
    Replies: 5
    Last Post: 06-30-2011, 01:42 AM
  2. Replies: 2
    Last Post: 03-23-2011, 11:13 AM
  3. Basic Query/totaling fields in a query
    By afisher in forum Queries
    Replies: 6
    Last Post: 08-05-2010, 01:43 PM
  4. Replies: 2
    Last Post: 04-30-2010, 09:43 AM
  5. Replies: 8
    Last Post: 03-29-2010, 10:20 AM

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