change a property sheet control depending on the selection selected on a radio field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DBlearner
    New Member
    • Oct 2009
    • 18

    change a property sheet control depending on the selection selected on a radio field

    Hello,

    I have been reading thru various questions in the Bytes forum and none really answers this completely so here I am.

    I have a radio button field that displays several options and you can only select one.

    My goal is to make a certain selection trigger a change in a text box. for example, if I select reject in the radio field then the text box background would go red.

    Will that require VBA? and is there an easy way to do this? any help will be awesomely appreciated

    Matt
  • ChipR
    Recognized Expert Top Contributor
    • Jul 2008
    • 1289

    #2
    This is a cool idea that you can do without any real code. Right click the text box and select Conditional Formatting. Now set a Condition to "Expression Is" and [YourOptionGroup Name] = 1, or whatever the value of that option is on the radio button's Data tab.

    Comment

    • DBlearner
      New Member
      • Oct 2009
      • 18

      #3
      I love Conditional formatting but I only can use up to three conditions. I probably will need at least 5 or 6. Plus I want to turn off/on some property sheet control too.

      Comment

      • ChipR
        Recognized Expert Top Contributor
        • Jul 2008
        • 1289

        #4
        You will need to write some code in the AfterUpdate event of the option group.

        Comment

        • DBlearner
          New Member
          • Oct 2009
          • 18

          #5
          Chip,

          Can you point me in the right direction regarding writing codes? There's so many different codes, etc. Can you give me the exact code name so I can google it and learn how to write, nest the code properly?

          I am so frustrated! I am almost done with the database except for this one ;-) any help would be so appreciated.

          Matt

          Comment

          • ChipR
            Recognized Expert Top Contributor
            • Jul 2008
            • 1289

            #6
            This will depend on what you want to do, but I'll try to point you in the right direction.

            In design view, open the Property Sheet for the Option Group. On the Event tab, find After Update and choose Code Builder. Access makes your procedure for you, which will be run when the event is triggered. It looks like:
            Code:
            Private Sub myOptionsGroup_AfterUpdate()
            
            End Sub
            Now you can put whatever code you want in there. Ignoring variables for now, we're going to use code to manipulate the Properties of some Control on the form. Say there is a text box on your form called myTextBox.

            You can refer to the properties of the text box with the . character. To find out what properties you can change, check the Textbox Object Members.

            Now, the default Property of a text box is .Value. This allows us to write
            Code:
            myTextBox = "hi"
            To set other properties we would write
            Code:
            myTextBox.BackColor = vbRed
            For each property, there is a page like TextBox.BackCol or Property that tells you what it does, when and how to set it, and gives examples.

            If you want to work with some other control, just look it up in the Access Object Model Reference and see what properties it has, and what you can set them to. After the textbox object, the Form object will probably be the most useful to learn.

            Sorry for the long post, but I hope this gets you where you want to go.

            Comment

            Working...