Results 1 to 15 of 15
  1. #1
    angybab is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Oct 2020
    Posts
    35

    Update text box when an option group radio button in selected

    I have text boxes on a form which uses radio buttons to switch between different views.
    I want the text in the boxes to change depending on the button chosen. I triedusing this code but its not working

    Private Sub Optionsbutton_click()
    Select Case Me.Optionsbutton
    Case 1
    Me.box1.Visible = False
    Me.box2.Visible = False

    Case 2
    Me.box1.Visible = True


    Me.box2.Visible = True

    Case 3
    Me.box1.Visible = True
    Me.box2.Visible = True

    End Select
    End Sub


    Private Sub optionsbutton_AfterUpdate()
    Select Case Me.optionsbutton
    Case 1
    Me.txtBox = "list of Departments"
    Case 2
    Me.txtBox = "list of Employees"
    Case 3
    Me.txtBox = "list of Clients"
    End Select
    End Sub

    the on click part works fine. Only the afterupdate part doesn't work.
    I will appreciate any help

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,535
    Only the afterupdate part doesn't work.
    That doesn't really tell us much. Any error message? Check that the code does actually fire by placing a breakpoint at the first line and then step though the code one line at a time with F8.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    angybab is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Oct 2020
    Posts
    35
    The error messege says: object doesn't support this property or method

  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,535
    And which line of code causes the error?
    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
    angybab is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Oct 2020
    Posts
    35
    If I select the button assigned to case 2 or case 3.
    The line Me.txtBox = "list of Employees" or line Me.txtBox = "list of Clients" is highlighted

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,535
    can you post a copy of the db
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    angybab is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Oct 2020
    Posts
    35
    oh it contains patients data, so I can't post it.
    But should is code correct or have I made a mistake some where?

  8. #8
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,535
    But should is code correct or have I made a mistake some where?
    I don't know, which is why I wanted to look at the actual db.
    oh it contains patients data, so I can't post it.
    Perhaps you could remove all sensitive data from the copy. Compact and repair. Then post it here as a zip file.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  9. #9
    angybab is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Oct 2020
    Posts
    35
    okay, it me see what I can do.

  10. #10
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,906
    You have created an option group and not just a single option haven't you.?

  11. #11
    angybab is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Oct 2020
    Posts
    35
    Yes, you are right

  12. #12
    angybab is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Oct 2020
    Posts
    35
    Hey Bob,
    I solved it be adding Caption to Me.txtBox
    thank you for the help
    best regards

  13. #13
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,535
    So Me.txtBox is a label and not a textbox as its name might suggest?
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  14. #14
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,906
    Well that cannot be correct, as otherwise option 1 would have raised an error as well?

  15. #15
    angybab is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Oct 2020
    Posts
    35
    Yes sorry, it's a label

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

Similar Threads

  1. Option group radio buttons
    By sharonir22 in forum Forms
    Replies: 3
    Last Post: 07-04-2015, 11:11 PM
  2. Replies: 4
    Last Post: 07-08-2013, 03:46 PM
  3. Replies: 2
    Last Post: 02-16-2013, 04:32 PM
  4. Replies: 6
    Last Post: 07-20-2011, 11:54 AM
  5. option group radio buttons
    By ManC in forum Forms
    Replies: 9
    Last Post: 03-08-2010, 03:46 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