Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Disabling a Control (A2K SR-1)

    I have a form with a drop-down box and 2 text boxes. Depending upon the selection made from the drop-down box, I want the user to be able to populate 1 of the 2 text boxes, but not the other. To prevent erroneous data entry, how can I 'lock out' either of the 2 text boxes depending on the selection made in the drop-down box? In the After Update for the drop-down box, can I disable the appropriate text box? Thanks for the help.

  2. #2
    4 Star Lounger SteveH's Avatar
    Join Date
    Jan 2001
    Location
    Chelsea, Gtr London, United Kingdom
    Posts
    587
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disabling a Control (A2K SR-1)

    Try this:
    <pre>If Me.cmbDropDown = "Something" Then
    Me.txt1.Enabled = True
    Me.txt2.Enabled = False
    Else
    Me.txt1.Enabled = False
    Me.txt2.Enabled = True
    End If
    </pre>

    You might want to lock/unlock the text boxes as well.
    HTH
    Steve H
    IT Lecturer/Access Developer
    O2K SR3/O2010; Win7Pro

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Disabling a Control (A2K SR-1)

    Or here's some alternative code:

    <pre> <font color=448800>'Evaluate the choice in the dropdown
    'Using the parens will return a true or false</font color=448800>
    [txtText1].Enabled = ([cboDropDown]="Something")
    <font color=448800>'set the other textbox to the opposite condition</font color=448800>
    [txtText2].enabled = not [txtText1].Enabled</pre>


    If you lock the textbox as well as disabling it, it won't gray out, which is the obvious way to show the user they can't do anything with that textbox right now.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •