combo box help !

database

Registered User.
Local time
Today, 14:59
Joined
Jun 3, 2004
Messages
80
Hello everyone !

I am designing a form on which I have a combo box with values yes/no and depeneding on whetehr it is ye or no, the textbox gets enabled. If the combobox value is yes, the textbox is enabled and if no, then it is not.

For the combo box i have written this code in the onchange event:

if me.combo2 = 1 then
me.textbox.enabled = true
else
me.textbox.enabled = false
end if

Whenever i load the form, a -1 is displayed in the combo box, I dont know why????????????

and the textbox gets disabled for any value i choose in the combo box.

Can anyone help me pleasE?

Thanks.
 
If they select yes or no in your combo box then why are you looking for the value 1?

If Me.Combo2.Value = "yes" Then
Me!textbox.Enabled = True
Else
Me!textbox.Enabled = False
End If

notice Me.Combo2.Value to get the value of the combobox

Hope that helps
-Jake
 
jdwhytie said:
If they select yes or no in your combo box then why are you looking for the value 1?

It might have two columns. ;)

Code:
If Me.Combo2.Value = "yes" Then
Me!textbox.Enabled = True
Else
Me!textbox.Enabled = False
End If

Me. not Me!

notice Me.Combo2.Value to get the value of the combobox

Notice that .Value is the default property of the combobox and is, therefore, unnecessary ;)

You want the AfterUpdate event too and not the Change.

As for the -1 appearing in the combobox once the form loads. Do you have anything in its Default Value property or is it bound to a number, text, or Yes/No field?

Of course, the question I have is why use a combobox? if you can only select Yes or No from it then a checkbox (or an option group) would seem more reliable.
 

Users who are viewing this thread

Back
Top Bottom