CmdButton enabled based on Combo Box data

  • Thread starter Thread starter Giberish
  • Start date Start date
G

Giberish

I have a CmdButton on a form that I need to be enabled based on data
that is already listed in a combo box.

I need the Command Button: TimeSheetButton to be enabled when the data
in my Combo Box: TypeID reads either "HOURLY" or "NON-EXEMPT" and
disabled if the combo box reads "EXEMPT."

Any suggestions on how I can make this work?
 
Set the enabled property of the command button to No.

In the Open event for your form

If Me!TypeID = "Exempt" then
Me!CmdButton.Enabled = false
Else
Me!CmdButton.Enabled = true
end if

If your form has multiple records, you'll need to also use that code in the
Current event for the form
 
Thank you for your reply, but I still cannot get this to work.

****************************************************
Private Sub Form_Current()
If Me!TypeID = "EXEMPT" Then
Me!TimeSheetButton.Enabled = False
Else
Me!TimeSheetButton.Enabled = True
End If

End Sub


'and also placed this on the on open

Private Sub Form_Open(Cancel As Integer)
If Me!TypeID = "Exempt" Then
Me!TimeSheetButton.Enabled = False
Else
Me!TimeSheetButton.Enabled = True
End If
End Sub
****************************************************

I tried this both on open and on current for the form. Neither appears
to be working.

Any other suggestions?
 
What is the name of the control that TypeID is bound to?
What is the name of the command button control?
 
1. What is the name of the control that TypeID is bound to?
::: The name of the control is TypeID

SELECT DISTINCTROW
[EmployeeType].[TypeID], [EmployeeType].[Type] FROM [EmployeeType];

"it is bound to column 1"

2. What is the name of the command button control?
::: The name of the command button control is TimeSheetButton
 
It seems to me that TypeID never contains "Exempt" or "HOURLY" or
"NON-EXEMPT" - those values are likely in the Type field - correct?

If so you need to change the code to
If Me!TypeID = 1 then
etc.
Of course change the 1 to the value in TypeID field that corresponds to the
Exempt Type in the EmployeeType table.
 
Thank you for all your help Joan!!!

I took this database over from someone else and I missed a simple step.
You were right that the TypeID never contained "Exempt." Instead, it
contained "E" and "H" and so forth. It didn't occur to me that this
might be the case until your last post. In any case, it works now.
Thanks again!!!
 
Back
Top