Link two Fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shreeks
    New Member
    • Jan 2009
    • 10

    #1

    Link two Fields

    I am newbie working on Access.
    I am asked to create a new database screen with "Letter Variables" as the field name.
    Letter variables is a radio button with Yes and No fields.
    If an Yes radio button is selected, additional fileds
    variable name ( a text box),
    Variable type ( a text box) ,
    variable field name( a text box),
    Variable Format ( a text box),
    must be visible and the user must be able to enter data into these text boxes. and when a No radio button is selected, the user is not allowed to enter the data into these text boxes.

    I am using forms and created radiobuttons with Yes or No fields. and also created the text boxes in the forms. Now Could any body explain me how to assosiate the radio button field with the textbox field.
  • DonRayner
    Recognized Expert Contributor
    • Sep 2008
    • 489

    #2
    First off you need to create an option group to hold your yes/no radio buttons. and then add the radio buttons to the option group.

    By default the option value property is set to 1 for the first radio button added 2 for the next and so on, or you can change them to whatever order you want.

    You can set either the yes or no buttons as the default for the option group. If you select the yes radio button as the default make sure that the enabled property is set to yes for all of the controls that you want enabled , if you set no as the default then make sure that the controls enabled propertys are set to no

    I'll assume that you have set yes = 1 and no = 2 and the option group name = Letter_Variable s.

    You would add code something like the following into the after update event of the Letter_Variable s control. FieldName1.... would be whatever the names of the text fields are that you want to control. you could also use the .visible property if you want to hide/show them.

    Code:
    Select Case Me.Letter_Variables
    Case = 1       'Yes button selected
    me.FieldName1.Enabled = true
    me.FieldName2.Enabled = true
    me.FieldName3.Enabled = true
    and so on.......
     
    Case = 2       'No button selected
    me.FieldName1.Enabled = false
    me.FieldName2.Enabled = false
    me.FieldName3.Enabled = false
    and so on.......
     
    Case Else
    Exit Sub
    End Select

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #3
      Radio Buttons don't work like that (See Don's post). It sounds like you actually need a CheckBox control instead.

      In short, Radio Buttons allow you to select (only) one item from a group. CheckBoxes allow you to set True or False (Yes / No).

      Bearing in mind the value of a standard CheckBox is either True or False, and that the .Locked property of a control is also either True or False, you can simply set the .Locked property to the value of the CheckBox any time that control is changed.
      Code:
      Me.[Variable Name].Locked = Me.[Letter Variables]
      Me.[Variable Type].Locked = Me.[Letter Variables]
      ...

      Comment

      Working...