Results 1 to 4 of 4
  1. #1
    caubetiep1337 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    22

    Uncheck Checkbox without directly referencing it

    I have several checkboxes, in each of them I want to call a sub that will uncheck the checkbox if some condition. Is there a code to reference active checkbox without explicitly referencing its name?
    Something like
    Code:
    Me.ActiveCheckbox = False

    Ideally I would have this!


    Code:
    Private Sub Chk1_Click()
    StrName = Name1
    Call CheckFile
    End Sub
    Private Sub Chk2_Click()
    StrName = Name2
    Call CheckFile
    End Sub
    
    Private Sub CheckFile()
    If some_condition_using_StrName Then
    Me.Checkbox = False 'that's what I want to achieve and avoid specifically referencing Chk1 = False or Chk2 = False
    End If
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Check out ActiveControl.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    caubetiep1337 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    22
    Good stuff. It works! Me(ActiveControl.Name) = False yay! Thanks a ton.

    Thread closed!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. VBA to uncheck ALL checkboxes in a subform
    By excellenthelp in forum Access
    Replies: 9
    Last Post: 05-05-2015, 02:17 PM
  2. Uncheck Radio Button?
    By taimysho0 in forum Programming
    Replies: 2
    Last Post: 06-29-2012, 03:44 PM
  3. Replies: 8
    Last Post: 05-25-2012, 11:42 AM
  4. Right Click checkbox to uncheck?
    By JubilantJeff in forum Forms
    Replies: 7
    Last Post: 12-19-2011, 02:12 PM
  5. Check/Uncheck Checkbox on "Enter" click
    By emilyrogers in forum Forms
    Replies: 2
    Last Post: 02-17-2011, 10:24 AM

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