Only allow CLose Command button if field = 0:00

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need help on an if function. I want a command button to work only if the
field is equal to 0. However, the problem I am having is that the field is a
time field. The function doesn't like "0:00". Thanks again.
 
Dogpigfish,

It is difficult to offer specific advice, on the basis of the very small
amount we know so far about what you are doing. You may need to use #
delimiters around the time value, if the field is a Date/Time data type.
Something like this?...
Me.YourCommandButton.Enabled = Me.YourTimeField = #0:00#
 
Thanks, that works great. However I keep getting a debug window when it
isn't equal to 0:00. How can I get a message instead saying "must equal 0:00"

This is the equation:

Private Sub Stopexit_Click()
Me.Stopexit.Enabled = Me.TTLTime = #12:00:00 AM#

DoCmd.Close

End Sub
 
Got it:
Private Sub Stopexit_Click()
If Me.TTLTime = #12:00:00 AM# Then
DoCmd.Close

Else
MsgBox "Unallocated Time must equal 0:00 time"

End If
End Sub

Thanks again
 
Back
Top