Results 1 to 8 of 8
  1. #1
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102

    Checkbox Click creates text in a text box


    I have two checkboxes, one called "Man" and the other "Woman". I want a text to appear in my textbox as soon as the user selects one of these checkboxes, which is called "WoderM".


    When the user clicks on "Man" this text should appear --> "M".


    When the user clicks on "Woman", this text should appear --> "F".


    How do I do this?


    My form looks like this if it helps:

    Click image for larger version. 

Name:	Screenshot 2022-11-09 155552.png 
Views:	21 
Size:	5.6 KB 
ID:	49064
    Attached Thumbnails Attached Thumbnails Screenshot 2022-11-09 155430.png  

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    I would have thought you would have an option group?, not two separate radio buttons, else you will need to unset one when the other is set?

    Just use an IF statement in the click event and set the field to the relevant value.

    BTW they are not checkboxes, but radio buttons. The clue is in the word box.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by Welshgasman View Post
    I would have thought you would have an option group?, not two separate radio buttons, else you will need to unset one when the other is set?

    Just use an IF statement in the click event and set the field to the relevant value.

    BTW they are not checkboxes, but radio buttons. The clue is in the word box.
    Code:
    Private Sub Mann_AfterUpdate()'Die Zeichenkette deklarieren
        Dim strM As String
        Dim strW As String
    'Die Zeichenkette auffüllen
        strM = "M"
        strW = "W"
    If IsNull(Forms!foOfferteInhalt!Mann) Then
            Me!WoderM = strM
        ElseIf !IsNull(Forms!foOfferteInhalt!Mann) Then
            Me!WoderM = strW
            
        End If
        
    End Sub
    I did it like this, but it isnt working do you know what to change?

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Why not just have a combo box from which the user can choose M or W
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    As I mentioned I would have an option group.
    Check out these videos https://www.youtube.com/results?sear...control+access

    Then it would be a case of
    Code:
    If OptGroup = 1 Then
         Me.WoderM = "M"
    Else
         Me.WoderM = "W"
    End If
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Thank you very much for the help!
    I did it with an option group in the end.

  7. #7
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    I agree with Bob, combo makes more sense.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Quote Originally Posted by Micron View Post
    I agree with Bob, combo makes more sense.
    Especially if you add all the other options which exist these days? :-)
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. Replies: 24
    Last Post: 03-12-2019, 08:02 PM
  2. Replies: 3
    Last Post: 10-28-2016, 03:18 PM
  3. Link to text file creates #Num! error on import
    By GregTheSquarePeg in forum Import/Export Data
    Replies: 8
    Last Post: 10-11-2013, 04:32 AM
  4. Using A Checkbox For A Text Field
    By LanieB in forum Forms
    Replies: 1
    Last Post: 04-12-2013, 06:18 AM
  5. Checkbox controlling text box
    By chuckduarte in forum Forms
    Replies: 0
    Last Post: 10-21-2008, 10:45 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