Results 1 to 8 of 8
  1. #1
    devcon is offline Novice
    Windows 7 Access 2007
    Join Date
    Jan 2010
    Posts
    24

    To check or Un-Check all Boxes in a form

    I’ve a form and on behind one query (orderqry). I like to create two button on the form to select all or partial check boxes.
    I found the following code but this is for a tablet. I don’t know how to fix in order to check the query.

    Private Sub cmdTick_Click()

    DoCmd.SetWarnings False
    DoCmd.RunSQL "UPDATE tblRecord SET tblRecord.ToPrint = True"
    DoCmd.SetWarnings True


    Me.Requery

    End Sub

    Private Sub cmdUnTick_Click()

    DoCmd.SetWarnings False
    DoCmd.RunSQL "UPDATE tblRecord SET tblRecord.ToPrint = False"
    DoCmd.SetWarnings True
    Me.Requery

    End Sub

    Any suggestion please?

  2. #2
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    is the checkbox status (on/off) a field on the table you are querying or unbound? If the former, that should work fine. Maybe add a Me.Refresh after the Me.Requery. If the latter:
    off - Me.checkbox = false ' (or = 0)
    on - Me.checkbox = true ' (or = 1)

  3. #3
    devcon is offline Novice
    Windows 7 Access 2007
    Join Date
    Jan 2010
    Posts
    24
    Thank you for your reply.
    Sorry but I don't understand what exactly to do.

    Here is the form 'ToPrint.png'
    And the query 'OrderQry.png'

    Can you explain me where I’ve to put the expression?
    Thank you for your help.

  4. #4
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    Ok I see what you need now. You dont need to have two command buttons there. It defeats the purpose of the checkbox. What you should do is have one button that will put "true" in the ToPrint if checked and "false" if not checked:

    if (me.chkbox = true) then
    DoCmd.SetWarnings False
    DoCmd.RunSQL "UPDATE tblRecord SET tblRecord.ToPrint = True"

    DoCmd.SetWarnings True
    Me.Requery
    Me.Refresh
    else
    DoCmd.SetWarnings False
    DoCmd.RunSQL "UPDATE tblRecord SET tblRecord.ToPrint = False"

    DoCmd.SetWarnings True
    Me.Requery
    Me.Refresh
    end if

    end sub

  5. #5
    devcon is offline Novice
    Windows 7 Access 2007
    Join Date
    Jan 2010
    Posts
    24
    Thank you for your reply.
    As I said I have one query 'OrdersQry' (join three tables), not one table 'tblRecord'. I have to use your code with this query.
    How I can use ‘DoCmd.RunSQL "UPDATE tblRecord SET tblRecord.ToPrint = True"’ if I don’t have the 'tblRecord' and I have only the query ‘OrdersQry’?

    Thank you for your help.

  6. #6
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    well, you are updating that table that the query is pulling ToPrint from. Allow me to illustrate.
    you have"
    Table Data ----> query ----> form

    you are updating the table that contains ToPrint. The Me.Requery will run the query that the form is based on, thus updating ToPrint on your form to whatever the new value is. Does this make sense?

  7. #7
    devcon is offline Novice
    Windows 7 Access 2007
    Join Date
    Jan 2010
    Posts
    24
    Thank you for your help, I solve my problem.
    Have a nice week end.

  8. #8
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    no problem. i hope i want totally useless. glad you made it work. please mark the thread solved =]

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

Similar Threads

  1. Replies: 2
    Last Post: 05-29-2014, 09:58 PM
  2. Un-Check all Boxes
    By cotri in forum Forms
    Replies: 4
    Last Post: 04-30-2010, 12:53 PM
  3. Check boxes for seating plans
    By carlpots76 in forum Access
    Replies: 2
    Last Post: 01-16-2010, 07:35 AM
  4. Replies: 0
    Last Post: 04-19-2008, 09:08 PM
  5. check boxes
    By chiefmsb in forum Forms
    Replies: 1
    Last Post: 11-14-2006, 02:22 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