Results 1 to 7 of 7

Thread: Form Problems

  1. #1
    Join Date
    Jun 2003
    Location
    UK
    Posts
    15

    Unanswered: Form Problems

    Hi,

    I have a form which has several radio buttons with two drop down combo boxes next to each. I am trying to get the combo boxes to be greyed out and not be able to be edited. When the radio button is selected I need the combo boxes next to them to become active and allow users to enter information. Also if they change their mind and disable the radio button the information they had selected in the combo boxes needs to be removed.

    I'm a bit new to this and I've managed to get the combo boxes to grey out, but I cannot do the rest. I've tried using the 'Enable = No' and 'Locked = No' commands but I cannot get them to work correctly.

    Any idea's?

    Thanks in advance

    Steve

    Code so far:

    Grey out boxes when Radio Button (Option157) is false this bit works OK

    Private Sub Option157_AfterUpdate()

    If Me!Option157 = True Then Me!Combo138.BackColor = 16777215 Else Me!Combo138.BackColor = 12632256
    If Me!Option157 = True Then Me!Combo140.BackColor = 16777215 Else Me!Combo140.BackColor = 12632256

    End Sub

    I have tried this also but it does not work correctly

    If Me!Option157 = False Then Me!Combo138.Enabled = No Else Me!Combo138.Enabled = Yes
    If Me!Option157 = False Then Me!Combo140.Locked = Yes Else Me!Combo140.Locked = No

  2. #2
    Join Date
    Mar 2004
    Location
    belgium
    Posts
    290
    If Me!Option157 = False Then Me!Combo138.Enabled = No Else Me!Combo138.Enabled = Yes
    If Me!Option157 = False Then Me!Combo140.Locked = Yes Else Me!Combo140.Locked = No

    try this instead :

    If Me!Option157 = False Then
    Me!Combo138.Enabled = No
    Me!Combo138.Locked = Yes
    Me!Combo140.Enabled = Yes
    Me!Combo140.Locked = No
    else
    Me!Combo138.Enabled = Yes
    Me!Combo138.Locked = No
    Me!Combo140.Enabled = No
    Me!Combo140.Locked = Yes
    endif

  3. #3
    Join Date
    Jun 2003
    Location
    UK
    Posts
    15
    Hi,

    I've added your code, It does disable and lock the combo boxes but they start off enabled when I load the form. I added in the following:

    Private Sub Form_Load()
    Me!Option157 = False
    Me!Combo138.Enabled = No
    Me!Combo138.Locked = Yes
    Me!Combo140.Enabled = No
    Me!Combo140.Locked = Yes
    Me!Combo138.Requery
    Me!Combo140.Requery
    End Sub

    This loads the form with the combo boxes disabled, however, when I click the radio button nothing happens to the combo boxes.

    Thanks

    Steve

  4. #4
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004
    Hi Steve,

    Why don't you try what I have in one of my databases. I have a CheckBox named "ChangeOfAddress" and the TextBox named "AddressChangeInfo." What happens is the TextBox to input the AddressChangeInfo is set as "Enabled.No". Then, for the CheckBox, on the OnClick event I did this:

    Code:
    Private Sub ChangeOfAddress_Click()
    'Created by BUD 12/11/2003.
    'When the ChangeOfAddress box is checked, the AddressChangeInfo section
     becomes live.
    
        AddressChangeInfo.Enabled = ChangeOfAddress
        
    End Sub
    That's all there is to it. So when you check the CheckBox the AddressChangeInfo TextBox comes alive (Enabled). The Reverse happens when you UnCheck the CheckBox.

    Hope this helps you out some.
    BUD

  5. #5
    Join Date
    Jun 2003
    Location
    UK
    Posts
    15
    Thanks BUD,

    Thats worked perfectly.

    Steve

  6. #6
    Join Date
    Mar 2004
    Location
    belgium
    Posts
    290
    that's a nice solution BUD. And Steve the following

    Private Sub Form_Load()
    Me!Option157 = False
    Me!Combo138.Enabled = No
    Me!Combo138.Locked = Yes
    Me!Combo140.Enabled = No
    Me!Combo140.Locked = Yes
    Me!Combo138.Requery
    Me!Combo140.Requery
    End Sub

    you can set in designview -properties, t isnt necessary to program it.

  7. #7
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004
    Quote Originally Posted by STEVE123456789
    Thanks BUD,

    Thats worked perfectly.

    Steve
    Sure thing Steve, just glad I was able to help you out. thanks to you too emiel.

    have a nice one,
    BUD

Posting Permissions

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