Results 1 to 6 of 6
  1. #1
    sud2017 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    148

    Checkbox to activate Textbox Value

    Hi Experts,



    I have a checkbox in my form, which when ticked should activate the value of a textbox. The textbox value is updated based on a combobox selection (1-30). There are many such textboxes in the form that get values based on the combobox selection, and I want to give user an option to use checkboxes to display values of textboxes, and when unchecked, display 0. For instance, this is how it will work, user selects combobox value 20, then few textboxes display the value 20, then the user checks few corresponding checkboxes to display 20, and unckecked ones to display 0.

    I found code something like this from a string, but this doesn't really display or makes 0 the textbox values. So perhaps some modification in below code will do my work.

    Code:
    Private Sub Check3_Click()
    If Me!Check3.Value = True Then
    Me!Text5.Enabled 
    = True
    Else
    Me!Text5.Enabled = False
    End If
    End Sub
    Your help will be much appreciated. Thank you.

  2. #2
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Why not just edit the textbox to zero? Checkboxes seem like unnecessary overhead to do that. You have to concern yourself with the opposite selection as in oops! I checked the wrong one, but when I uncheck it, I don't get my value back.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Code:
    Private Sub Check3_Click()
    If Me.Check3.Value = True Then
         Me.Text5.Enabled = True
    Else
         me.text5.enabled = true
         Me.text5 = 0
         Me.Text5.Enabled = False
    End If
    End Sub
    Edited code to ensure that text5 was enabled before setting value.
    . is preferable to ! here

  4. #4
    SierraJuliet's Avatar
    SierraJuliet is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2017
    Location
    Earth
    Posts
    211
    A check box is designed to =

    1 or 0
    On or Off
    Yes or No
    True or False

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Except UNBOUND checkbox can be set to triple state. Null is the third state. Never used. I avoid checkboxes in general.

    Use Conditional Formatting instead of VBA to set Enabled state of textbox, especially if form is in Datasheet or Continuous view.
    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.

  6. #6
    SierraJuliet's Avatar
    SierraJuliet is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2017
    Location
    Earth
    Posts
    211
    Quote Originally Posted by June7 View Post
    Except UNBOUND checkbox can be set to triple state. Null is the third state. Never used. I avoid checkboxes in general.

    Use Conditional Formatting instead of VBA to set Enabled state of textbox, especially if form is in Datasheet or Continuous view.
    There is no nerd emoji on here

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

Similar Threads

  1. Activate button when 2 checkbox are checked
    By BigJohn89 in forum Programming
    Replies: 2
    Last Post: 12-31-2017, 07:11 AM
  2. checkbox and Textbox link
    By rebel_yell in forum Access
    Replies: 10
    Last Post: 05-13-2014, 04:46 PM
  3. Replies: 8
    Last Post: 11-19-2012, 09:22 AM
  4. Insert Multiple Checkbox Values to one Textbox
    By dshillington in forum Programming
    Replies: 1
    Last Post: 12-28-2011, 10:10 AM
  5. Combining textbox and checkbox data
    By jgarner in forum Access
    Replies: 0
    Last Post: 12-11-2008, 11:10 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