Results 1 to 4 of 4
  1. #1
    mortonsafari is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jul 2015
    Location
    Brisbane, Queensland, Australia
    Posts
    39

    Code/Macro for Find and Replace with Checkbox

    I have a database in which the user can select records to print via a checkbox (Yes/No | True/False | -1/0 as the case may be) and then a query that runs through a form to show the list of the records selected with the Print checkboxes as Yes | True | -1.
    I want to include a button to change the checkbox for each record from Checked back to Unchecked (Yes back to No | True back to False | -1 back to 0).
    Rather than have to Uncheck each individual record, I’d like to have a Macro or Code that will do all the displayed records in one hit.
    I have looked at Code and Macro but can’t seem to find a “Find and Replace” type action that will allow me to do it all in one go.


    Can anyone suggest an answer for me please.
    Many thanks, mortonsafari

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,943
    Users should not work directly with tables and queries - only forms and reports.

    Easiest is an sql UPDATE action to set all records in table to 0.

    CurrentDb.Execute "UPDATE tablename SET fieldname=False"
    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.

  3. #3
    mortonsafari is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jul 2015
    Location
    Brisbane, Queensland, Australia
    Posts
    39
    Thanks June7. The users are only selecting records via a Form and selecting the Checkbox there. They then select the other form to allow them to Unselect the checkbox. I just want to make it easier to Uncheck all the Checked boxes.

  4. #4
    mortonsafari is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jul 2015
    Location
    Brisbane, Queensland, Australia
    Posts
    39
    Thanks June7. Sorted it out by

    Private Sub Command6_Click()
    CurrentDb.Execute "UPDATE q_ClearPrintBox SET Print=False"
    Me.Refresh
    End Sub

    Many thanks

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

Similar Threads

  1. Find and Replace in Macro and VB
    By Baldeagle in forum Macros
    Replies: 4
    Last Post: 01-28-2014, 10:32 AM
  2. Find and Replace Macro
    By TrevorM in forum Macros
    Replies: 11
    Last Post: 12-28-2013, 06:11 PM
  3. Replies: 8
    Last Post: 01-17-2012, 02:43 PM
  4. Find and Replace Within a Macro
    By bmschaeffer in forum Access
    Replies: 1
    Last Post: 12-20-2011, 11:27 AM
  5. Find and Replace
    By Bedsingar in forum Access
    Replies: 1
    Last Post: 08-14-2011, 01:10 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