Using Combox.enable

scopes456

Registered User.
Local time
Yesterday, 20:20
Joined
Feb 13, 2013
Messages
89
Hi, I have two combo box (cb1, and cb2) I would like to enable and disable cb2 when certain values in cb1 is selected. cb1 I have two fields ( ID ,Reason). I used the following code, which works great when I use one value after the like statement. ( when I select ID 1 on cb1 it disables cb2). But what if I want to select a different value , for example 2, it will not work. I tried writing the statement again and insert a 2, but it just ignores it .



Me.cb2.Enabled = Nz(Me.cb1.Value, vbNullString) Like "1"
 
Uncle Gizmo, I did put it on cb1 after update event, it works find when its one value
Me.cb2.Enabled = Nz(Me.cb1.Value, vbNullString) Like "1" but it I write it like this

Me.cb2.Enabled = Nz(Me.cb1.Value, vbNullString) Like "1"
Me.cb2.Enabled = Nz(Me.cb1.Value, vbNullString) Like "2"
Me.cb2.Enabled = Nz(Me.cb1.Value, vbNullString) Like "3"

it would not work, I would like it when I select different values in this case 1,2, or 3, cb2 will be enabled
 
What you have written makes no sense to Access.
Enabled is either true or false, like "1" "2" or "Bananas" is meaningless.
 
Minty - I have a combobox label cb1 that tracks employees , when I select certain employees I want combobox cb2 to be enable. I found the follow code

Me.cb2.Enabled = Nz(Me.cb1.Value, vbNullString) Like "1" where "1" is the value of combobox cb1 (ID Field), so when I select the employee with ID 1 then cb2 is enabled. I would like when I select , employee number 2, or 3, or 10 on cb1 , that cb2 will be enable.
 
Select case WhatToTest
Case 1, 2,....
Me.cb2.enabled = true
Case else
Me.cb2.enabled = false
End select
 
smig - thank you , using case statement works perfect
 

Users who are viewing this thread

Back
Top Bottom