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

    How to include optional field in querydesign mode

    I have search form which is based on a requery on a subform .The subform record source has the query with fours fields. (2 optional 2 mandatory) .How to write in the criteria section for the coumn (in the query design mode) which are optional . Any help is appreciated.

  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,847
    Perhaps some sample data would help, but my first thought for the query is

    Select mandatoryFld1, MandatoryFld2, Opt1 , Opt2 from MyTable
    where
    mandatoryFld1 is Not Null and
    mandatoryFld2 is Not Null

  3. #3
    pratim09 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Apr 2011
    Posts
    30
    I tried the below query but still its not working . I ma not getting any row returned .The name and date is mandatory in the query .Any help on this plz?

    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 ([Forms]![frmHoursTrackingModify]![Name] Is Not Null) AND ((TBL_HOURS_TRACKING.ActualMonth) Between [Forms]![frmHoursTrackingModify]![txtStartDate] And [Forms]![frmHoursTrackingModify]![txtEndDate] Is Not Null));

  4. #4
    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,847
    If you're running this query from a button on a form, I'd recommend you insert some vba
    to do some debug.print statements.
    Check and see what the values are for
    [Forms]![frmHoursTrackingModify]![cmbProjectName]
    [Forms]![frmHoursTrackingModify]![WorkId]
    [Forms]![frmHoursTrackingModify]![Name]
    [Forms]![frmHoursTrackingModify]![txtStartDate]
    [Forms]![frmHoursTrackingModify]![txtEndDate]

    My guess is that no records meet your criteria.

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

Similar Threads

  1. Only include unique occurances
    By filla_dilla in forum Queries
    Replies: 8
    Last Post: 07-18-2011, 10:22 PM
  2. SQL query with an optional date field
    By StevenBee in forum Programming
    Replies: 1
    Last Post: 05-30-2011, 02:40 PM
  3. Exclude LATE but include empty
    By dhborchardt in forum Queries
    Replies: 2
    Last Post: 04-15-2011, 01:10 PM
  4. Replies: 4
    Last Post: 01-14-2011, 10:37 AM
  5. include zero data where no record
    By Sandy Gomez in forum Access
    Replies: 4
    Last Post: 09-15-2010, 06:23 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