Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling a command button when a combobox is null 1

Status
Not open for further replies.

TeriCoombes

Technical User
Aug 26, 2004
22
US
I have a form that requires the user to select a test name and their name before enabling a command button that allows them to enter data. However, I can go to the form, delete the name, and still have the command button enabled. How do I disable it when the selection is null? Here is my code so far:

Private Sub cboAnalyst_Change()
cmdLogIn.Enabled = True
End Sub

I have tried inserting an if...then...else statement, but that just causes problems and I have to debug.
 
Private Sub cboAnalyst_Change()
If Len(cboAnalyst) <> 0 then
cmdLogIn.Enabled = True
Else
cmdLogIn.Enabled = False
End If
End Sub


I am what I am based on the decisions I have made.

DoubleD [bigcheeks]
 
Something like this ?
cmdLogIn.Enabled = Not IsNull(cboAnalyst)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I figured out what my problem was. PHV, your code worked when I changed the procedure to After Update instead of On Change(). Thanks. [thumbsup2]
 
And this ?
cmdLogIn.Enabled = (cboAnalyst.ListIndex >= 0)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top