Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

check - uncheck in a continuous form

Discussion in 'Information Technology' started by jean.ulrich@snclavalin.com, Jul 28, 2006.

  1. jean.ulrich@snclavalin.com

    jean.ulrich@snclavalin.com
    Expand Collapse
    Guest

    Hi

    I have an unbound form name "Letter "
    On this form I have a continuous form named "frmEmployees" linked
    with the table "tblEmployees"
    In the continuous form I have many fields including "City" and
    "Choice" both linked with table "tblEmployees"
    Field "Choice" is a check box (yes/no)

    Suppose I make a filter on New-York city, I want to use a button placed
    on the from header of the "frmEmployees" that when I click on it
    all the check boxes "Choice" for New-York will become checked.
    Then I filter for Denver and by clicking the same button, all the
    "Choice" check boxes for Denver will be checked
    Of course I can check some other records if I want
    So at the end all check boxes for New-York all check boxes for Denver
    plus all other single boxes I have check are checked.

    I also want a second button that I will use to uncheck all check boxes.

    Thanks for helping me
     
  2. Loading...


  3. Allen Browne

    Allen Browne
    Expand Collapse
    Guest

    Use the AfterUpdate event procedure of the unbound check box to execute an
    Update query statement so that all the entries matching the form's filter
    are set to Yes

    Private Sub chk1_AfterUpdate
    Dim strSql As String
    If Me.chk1.Value And Me.FilterOn Then
    If Me.Dirty Then 'Save first
    Me.Dirty = False
    End If
    strSql = "UPDATE [Table1] SET Choice = True WHERE " & Me.Filter
    dbEngine(0)(0).Execute strSql, dbFailOnError
    End If
    End Sub

    To reset all boxes to unchecked again, execute this string:
    strSql = "UPDATE [Table1] SET Choice = False WHERE Choice = True;"

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    <jean.ulrich@snclavalin.com> wrote in message
    news:1147598828.640995.240100@g10g2000cwb.googlegroups.com...
    >
    > I have an unbound form name "Letter "
    > On this form I have a continuous form named "frmEmployees" linked
    > with the table "tblEmployees"
    > In the continuous form I have many fields including "City" and
    > "Choice" both linked with table "tblEmployees"
    > Field "Choice" is a check box (yes/no)
    >
    > Suppose I make a filter on New-York city, I want to use a button placed
    > on the from header of the "frmEmployees" that when I click on it
    > all the check boxes "Choice" for New-York will become checked.
    > Then I filter for Denver and by clicking the same button, all the
    > "Choice" check boxes for Denver will be checked
    > Of course I can check some other records if I want
    > So at the end all check boxes for New-York all check boxes for Denver
    > plus all other single boxes I have check are checked.
    >
    > I also want a second button that I will use to uncheck all check boxes.
    >
    > Thanks for helping me
     
  4. jean.ulrich@snclavalin.com

    jean.ulrich@snclavalin.com
    Expand Collapse
    Guest

    Hi
    there is no unbound check box
    Check box "Choice" is a field in "tblEmployees"
    so i cannot us the after update event like you said
    Script should be place on the On Click event of the button

    thanks
     
  5. Allen Browne

    Allen Browne
    Expand Collapse
    Guest

    Okay. Put the code in the click event of your command button.

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    <jean.ulrich@snclavalin.com> wrote in message
    news:1147608423.445336.60550@j55g2000cwa.googlegroups.com...
    > Hi
    > there is no unbound check box
    > Check box "Choice" is a field in "tblEmployees"
    > so i cannot us the after update event like you said
    > Script should be place on the On Click event of the button
    >
    > thanks
     
  6. jean.ulrich@snclavalin.com

    jean.ulrich@snclavalin.com
    Expand Collapse
    Guest

    Thank Allen

    The code was ok to put on the button except for the
    "If Me.chk1.Value And Me.FilterOn Then "
    that I have to replace by
    "If Me.FilterOn Then "

    Thanks gain, it works fine now
     

Share This Page