getting a compile error not sure why

  • Thread starter Thread starter babs
  • Start date Start date
B

babs

I have written an event procedure for after the cost combo box is selected
that if the value is NOT equal to 0 I do not want the field truckhours to be
able to be input and if it is 0 they truck hours can be input.

Private Sub cbocost_AfterUpdate()
If (Me.cost) <> 0 Then
Me.TruckHours1.Enabled = False
Else
Me.TruckHours1.Enabled = True
End If
End Sub

not sure what I have wrong
thanks,
Barb
 
It would help to know the exact error message you're getting.

However, you imply that decision is based on what was selected in the combo
box. In one place, the combo box is called cbocost, in the other, it's
simply cost. Try changing

If (Me.cost) <> 0 Then

to

If (Me.cbocost) <> 0 Then
 
The name of your combo box appears to be cbocost, so it would need
to be;

Private Sub cbocost_AfterUpdate()
If (Me.cbocost) <> 0 Then
Me.TruckHours1.Enabled = False
Else
Me.TruckHours1.Enabled = True
End If
End Sub
 
Back
Top