Lock/Disable cbobox

JPR

Registered User.
Local time
Today, 13:57
Joined
Jan 23, 2009
Messages
207
hello and thank you for any help you can provide me.

I have a form with multiple combo boxes. Each combo gets populated according to the selection of the other combo.

I would like that when I select a specific record in combo1, combo 2 get's grayed out (locked) as an additional selection is not required.

I have tried with the following code in both the current event of the form and the After Update but it does not work:

If me.cbo1.value "Hello" Then
me.cbo2.enable = false
else
me.cbo2.enable = true
end if

Unfortunately does not work.
THank you
 
Try:
Code:
If me.cbo1.value [COLOR="Red"]=[/COLOR] "Hello" Then
me.cbo2.enable[COLOR="red"]d[/COLOR] = false
else
me.cbo2.enable[COLOR="red"]d[/COLOR] = true
end if
 
Thank you.

The combo (combo2) now does get disabled but if I chance my selection in combo1, it does not get enabled. Its stays grayed out.
 
If you've copied to code correctly it should work for you as it does for me.
Have you tried to complie the code
Please show us the code you are now using or upload a copy of your database.
 
I agree that should work. You can also do this in one line

Me.cbo2.enabled = (me.cbo1.value <> "Hello")
 
Solved.
I just changed my code as follows and works. Thank you

Form_Current()

If Me.cbo1.Value = "Hello" Then
Me.cbo2.Enabled = False

If Me.cbo1.Value <> "Hello" Then
Me.cbo2.Enabled = True
End If
End If


cbo1_AfterUpdate()

If Me.cbo1.Value = "Hello" Then
Me.cbo2.Enabled = False


If Me.cbo1.Value = "Any other selection except Hello" Then
Me.cbo2.Enabled = True
End If

end if
 
Does that actually work?:confused:

Code:
Form_Current()

If Me.cbo1.Value = "Hello" Then
    Me.cbo2.Enabled = False

    If Me.cbo1.Value <> "Hello" Then
        Me.cbo2.Enabled = True
    End If
End If


cbo1_AfterUpdate()

If Me.cbo1.Value = "Hello" Then
    Me.cbo2.Enabled = False


    If Me.cbo1.Value = "Any other selection except Hello" Then
        Me.cbo2.Enabled = True
    End If

end if
 
The AfterUpdate event will definitely not work if you test it thoroughly.
Try using e.g. "Goodbye" in the combo. The enabled state of the other combo won't change.

Also the Form_Current event code is over complex.

Suggest you scrap both bits of code and just use the code supplied by Bob Fitz or MajP in the after update event
 

Users who are viewing this thread

Back
Top Bottom