Text box enabled based upon various combo box values

jjake

Registered User.
Local time
Today, 14:52
Joined
Oct 8, 2015
Messages
291
Hello,

I have a text box "Txt1"

And multiple Combo Boxes "Cbo1" "Cbo2" "Cbo3" all on a form "frm1"

The combo box options are 1 = Yes, 2 = No.

I would like it if either cbo1, 2 or 3 are "No" or "Null" then txt1 will be disabled. This would change as the combo boxes are changed.

E.g

The form is opened and the default enabled status for txt1 is false. cbo1 is selected "Yes" then txt1 would stay disabled because cbo2 and cbo3 are still empty.

if cbo2 is "Yes" and cbo3 is then marked "No", then txt1 will stay disabled because a "No" option has been selected. The only time that txt1 will be enabled is if all combos have a "Yes"/1 value.

These boxes may be updated in sequential order or at random. e.g cbo3 is changed first then cbo1 then cbo2.


The txt1 will need to be updated/refreshed after each option has been made. This is installed on a split database so multiple users may be changing a combo box at the same time.

The idea is to allow multiple users to give their agreement (Yes/No) before a final text box can be filled with text and only if all users have given a yes response.

Thanks,

Jake.
 
On the form' s load event:
Code:
Private sub form_load()
Dim c1 As byte, c2 as byte,  c3 as byte

C1=Nz([cbo1], 1)
C2=Nz([cbo2], 1)

C3=Nz([cbo3], 1)

Me.txt1.enabled=((c1 + c2 + c3)>5)
End sub

On each combo's AfterUpdate Events, insert this line.
Code:
Call Form_Load
 
On the form' s load event:
Code:
Private sub form_load()
Dim c1 As byte, c2 as byte,  c3 as byte

C1=Nz([cbo1], 1)
C2=Nz([cbo2], 1)

C3=Nz([cbo3], 1)

Me.txt1.enabled=((c1 + c2 + c3)>5)
End sub

On each combo's AfterUpdate Events, insert this line.
Code:
Call Form_Load


Arnelgp,

This worked well for when a person selected the "No" option but it still enables box1 if a combobox is left blank/empty. Also i have to refresh the form after every combo change for the changes to take effect. Would i use the requery option in this instance?
 
Add code to the forms current event:

Private sub form_current()
On error resume next
Call form_load
End sub
 
After messing around with coding, i still had an issue with not all boxes staying enabled/disabled correctly. I ended up using Conditional formatting on the text box.
 

Users who are viewing this thread

Back
Top Bottom