Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Peter Simpson is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Oct 2017
    Location
    South Africa
    Posts
    83

    Using yes/no function

    Is it possible to use a yes/no checkbox on an access form that will hide the corresponding data in the table?

    What I want to do is tick the yes/no checkbox on the form when the task is complete which will automatically hide that row of data in the table so only incomplete tasks are visable.

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Sure. You'll have to modify the form's recordsource SQL WHERE clause to something like
    WHERE chkCompleted <> True

  3. #3
    Peter Simpson is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Oct 2017
    Location
    South Africa
    Posts
    83
    thank you for that but I have no idea what you just conveyed to me...sorry, I am a novice and what you said went over my head. Can you please simplify?

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    your form that has the records is based on the source: table (or a query to show all records)
    change the source to a query : qsActiveRecs

    this query will filter out the checkmarked recrords

    qsActiveRecs= select * from table where [checkbox]=false
    set the form to this so users cannot see the checked records.

  5. #5
    Peter Simpson is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Oct 2017
    Location
    South Africa
    Posts
    83
    Ok so step 1 would be to create a query that is identical to the original table?

  6. #6
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    In form design, go to the properties for the form and click on the three dots next to the Record Source property. That will bring up the query design window. Then use the * to select all records from the table, in addition bring in the check box and in the criteria line add =False.

    Then, go to the checkbox field. In the AfterUpdate event, select [Event Procedure], click on the three dots and type this:
    Me.Requery

    That will repaint the screen and will get rid of the record that you have just set to True.

    Note: Once you have set this to true the record will disappear. Usually there needs to be a way to reverse this entry in case it was done in error. You will need to decide how you want this to happen.
    Also, a checkbox is not a good method of marking something complete, this is usually done with a date field so that there is more information than just a yes or no. Sometimes the user name is also kept track of. You need to think of the future and what you will need to know about completed transactions. This can be automated, as in when they click on the checkbox you set the date to Now().

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Do you have the Yes/No field in table that the checkbox is bound to? Or a date/time field for storing the date of completion?
    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.

  8. #8
    Peter Simpson is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Oct 2017
    Location
    South Africa
    Posts
    83
    You guys have given me a lot to think about, thank you.

    You are right that I don't want the record to disappear forever. Ideally it should be moved into a sort or archive table (not sure that it is even possible though).

    Currently, I have a query set up that only shows the records that are unresolved, which gives me the assurance that the resolved records are still available should I need to access them or relook at them. The problem is that in my SplitForm all the records (resolved and unresolved) are displayed. This can be quite cumbersome and would be a "nice to have" if only the unresolved records were displayed.

  9. #9
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    You can put 2 buttons on the form: "Show Resolved" and "Show Unresolved". The on-click event for each button would change the recordsource for the form to a query that shows the desired records.

  10. #10
    Peter Simpson is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Oct 2017
    Location
    South Africa
    Posts
    83
    devegri....you are my hero

    Can you please help me with that? I have never written proper code using the on-click event

  11. #11
    Peter Simpson is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Oct 2017
    Location
    South Africa
    Posts
    83
    Ok, so I managed to set up the button for Show Unresolved....when I click it he query opens up perfectly. Can I have the query open up on a section of the form so that I can see both the form and the query on one page?

  12. #12
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    No, I don't think you want to do that. You don't want to show the actual query itself. You want the form to show the query results. Do this.
    Create another query to show resolved.
    Let's say your query names are qRes and qUnRes.
    On your form you have the buttons named cmdRes and cmdUnRes.
    For the on-click event for cmdRes
    Code:
    Me.recordsource = qRes
    For the on-click event for cmdUnRes
    Code:
    me.recordsource = qUnRes

  13. #13
    Peter Simpson is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Oct 2017
    Location
    South Africa
    Posts
    83
    Ok...I did that but then all my fields become errors and unuseable

  14. #14
    Peter Simpson is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Oct 2017
    Location
    South Africa
    Posts
    83
    Original Form

    Click image for larger version. 

Name:	Form.jpg 
Views:	15 
Size:	75.8 KB 
ID:	31291

    Form after the "click"

    Click image for larger version. 

Name:	Form2.jpg 
Views:	16 
Size:	96.4 KB 
ID:	31292

  15. #15
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Sorry, add quotes around the query name:
    Me.Recordsource = "qRes"
    Me.Recordsource = "qUnRes"

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 15
    Last Post: 05-31-2017, 02:10 PM
  2. Replies: 2
    Last Post: 02-26-2017, 11:31 AM
  3. Replies: 3
    Last Post: 03-04-2016, 10:36 AM
  4. Replies: 8
    Last Post: 11-04-2014, 10:44 PM
  5. Replies: 8
    Last Post: 01-31-2014, 01:45 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