Results 1 to 10 of 10
  1. #1
    raffyT is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2014
    Posts
    5

    Filtering data with date and check boxes

    Hi.. I am new in MS Access programming and is trying to create a search form for all records based on selected dates and check box. I was able to filter the records by dates but can't find ways to filter the records that meet the dates to be filtered again based on the selected check box/s. Basically what I wanted to is display all the records within the selected dates and check box/s.



    Click image for larger version. 

Name:	search form.JPG 
Views:	20 
Size:	45.7 KB 
ID:	17927

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Add the check box criteria to your query. Example: True or -1 for Person1

    HTH

  3. #3
    raffyT is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2014
    Posts
    5
    Quote Originally Posted by burrina View Post
    Add the check box criteria to your query. Example: True or -1 for Person1

    HTH
    Thanks for the reply..

    this is what I have on the Click Event. What I want to do is to display record/s of person/s that I tick (checkbox) that match the date I selected. I was able to do it if one name is checked, however not if two or more names is ticked.. (btw, I used 1, 2, 3,4 as filter for each name.)

    Private Sub cmdbydate_Click()
    On Error GoTo cmdbydate_Click_Err
    If (chkPersonl = -1) Then
    DoCmd.SetFilter "", "[OpenedBy] Like ""1"" And [OpenedDate] Between [txtStartDate] And [txtEndDate]", "SearchResult"
    ElseIf (chkPerson3 = -1) Then
    DoCmd.SetFilter "", "[OpenedBy] Like ""2"" And [OpenedDate] Between [txtStartDate] And [txtEndDate]", "SearchResult"
    ElseIf (chkPerson4 = -1) Then
    DoCmd.SetFilter "", "[OpenedBy] Like ""3"" And [OpenedDate] Between [txtStartDate] And [txtEndDate]", "SearchResult"
    If (chkPersonl = -1) Then
    DoCmd.SetFilter "", "[OpenedBy] Like ""4"" And [OpenedDate] Between [txtStartDate] And [txtEndDate]", "SearchResult"
    Else
    DoCmd.SetFilter "ShowAll", "[OpenedBy] Like ""*"" And [OpenedDate] Between [txtStartDate] And [txtEndDate]", "SearchResult"
    End If

    cmdbydate_Click_Exit:
    Exit Sub
    cmdbydate_Click_Err:
    MsgBox Error$
    Resume cmdbydate_Click_Exit
    End Sub

  4. #4
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Do you ONLY want to allow one check box to be checked? If so, use the AfterUpdateEvent to Disable the others.

  5. #5
    raffyT is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2014
    Posts
    5
    nope. I want to display records of all the names that has been checked.

  6. #6
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    So, then do you have All of those persons in your query? i.e. Person1,Person2 etc...?

  7. #7
    raffyT is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2014
    Posts
    5
    I was able to display the record correctly if only ONE name is checked, but NOT if two or more is checked.

  8. #8
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    You already said that, I asked you if ALL of those Persons were in your query grid! Are they? Post your query record source for your search.
    Do you have 2, 3 and 4 values in your query?

  9. #9
    raffyT is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2014
    Posts
    5
    Hi.. sorry but I'm totally lost here.. is this the one you're asking..

    SELECT Issues.OpenedBy, Issues.OpenedDate, Issues.Ticket, Issues.Server, Issues.Priority, Issues.AssignedTo, Issues.Status
    FROM Issues
    WHERE (((Issues.OpenedBy) In (SELECT [OpenedBy] FROM [Issues] As Tmp GROUP BY [OpenedBy],[OpenedDate] HAVING Count(*)>1 And [OpenedDate] = [Issues].[OpenedDate])))
    ORDER BY Issues.OpenedBy, Issues.OpenedDate;

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Cannot build filter criteria based on these multiple checkboxes into the query (or at least it would be very difficult). Use VBA to construct filter string and apply to Filter property of form or pass to form or report when opened.

    Review:
    http://www.allenbrowne.com/ser-62code.html
    http://www.allenbrowne.com/ser-50.html

    You need to build an IN clause for the multiple parameters for the OpenedBy field or an expression with OR operators. The second link shows code for selecting multiple items with a listbox to construct IN clause.

    Advantage of listbox over checkboxes is if need more or less than 4 persons or change person names, don't have to modify form design.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Check boxes to add data?
    By PaintTheMoonRed in forum Access
    Replies: 1
    Last Post: 04-18-2014, 09:14 AM
  2. Check Boxes saving log in data?
    By Z1nkstar in forum Access
    Replies: 1
    Last Post: 03-20-2014, 01:29 PM
  3. Replies: 15
    Last Post: 11-18-2013, 10:49 PM
  4. Replies: 3
    Last Post: 08-15-2013, 10:43 AM
  5. Replies: 5
    Last Post: 07-26-2012, 02:30 PM

Tags for this Thread

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