Results 1 to 5 of 5
  1. #1
    Medicmike is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    3

    Checkbox question

    Hello,

    Am new to this forum and fairly new to access but I am needing to have a checkbox, when clicked on a form, change the third character in a four character textbox. I have figured out how to "OnClick" of the checkbox change the color of the textbox in question but can't get the code right to change the text. When it is checked, I need the character to change from whatever it is, to a "G". I know I need to use the Replace function, but that is the extent of my current knowledge.

    Any help would be appreciated.



    Thanks,

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    You should try something like this in your On Click:

    [I'm calling the textbox txt1 and the checkbox chk1]

    Code:
     
    Dim txt1Text as String
     
    If chk1.Value = True Then
        txt1.SetFocus
        txt1Text = Left(Me.txt1.Text, 3) & "G"
        txt1.Text = txt1Text    
    End If

  3. #3
    Medicmike is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    3

    Almost works

    Thanks for replying Robeen,

    The code does change a character to G, but it changes the fourth one, so I tried changing the string to a 2, and that did change the third character but then it also deletes the fourth character.

    After it makes the update then i also get a runtime error 2115 and the debuger highlights the last line in the code "JAC_Code.Text = JAC_CodeText".

    suggestions?

  4. #4
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Change this:
    txt1Text = Left(Me.txt1.Text, 3) & "G"

    to:
    txt1Text = Left(Me.txt1.Text, 2) & "G" & Right(Me.txt1.Text,1)

    That should give you the result you are looking for.

    Hope that helps!!

  5. #5
    Medicmike is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    3
    That did it. thanks a bunch!

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

Similar Threads

  1. QBF - Checkbox
    By radink in forum Queries
    Replies: 17
    Last Post: 04-19-2011, 03:47 PM
  2. Checkbox Question
    By markod in forum Forms
    Replies: 4
    Last Post: 11-09-2010, 05:43 PM
  3. Checkbox
    By Patience in forum Access
    Replies: 5
    Last Post: 06-22-2010, 05:37 AM
  4. Yes/No Checkbox Question
    By Richard in forum Access
    Replies: 3
    Last Post: 10-07-2009, 03:14 PM
  5. easy checkbox question
    By nelsok in forum Forms
    Replies: 1
    Last Post: 06-09-2006, 05:46 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