Trying to get an If/Else statement to operate

Compredneck

New member
Local time
Today, 12:58
Joined
Dec 14, 2005
Messages
7
Hello:

I have created a form that lets an end user enter data. I want to create an end/if statement on one of the combo boxes. In the combo box, there is a yes, no. There are two textboxes that work with the yes/no question. I would like the form to disable the textboxes if no is entered. If someone would be kind enough to point me in the right direction that would be cool. :cool:

Thanks,

Compredneck
 
Try something like this after update of the checkbox:

if chk1.value = true then
[txt1].locked=true
[txt2].locked=true

else

[txt1].locked=false
[txt2].locked=false

end if
 
Sorry, just noticed is a combo box, so try something like this after update of the combobox:

if cmb1.value = "No" then
[txt1].locked=true
[txt2].locked=true

else

[txt1].locked=false
[txt2].locked=false

end if
 
macca the hacke said:
Sorry, just noticed is a combo box, so try something like this after update of the combobox:

if cmb1.value = "No" then
[txt1].locked=true
[txt2].locked=true

else

[txt1].locked=false
[txt2].locked=false

end if
Macca,

Thanks for the help, but it is not operating efficiently. The After Update will not take place right then. I am wondering if I could put the code in another event so that it would work when I do the field.

Compredneck:eek:
 
I would try the On change event - instead of locking the field, you can also try to disable it altogether and it allows the user to visually see that its not accessible.

Code:
Private Sub Combo2_Change()
        
If Cmb1.Value = "No" Then
[txt1].Enabled = False
[txt2].Enabled = False

Else

[txt1].Enabled = True
[txt2].Enabled = True

End If

End Sub

hth
John D
 

Users who are viewing this thread

Back
Top Bottom