If (Start_Date = Int(Start_Date)) And Not IsNull(Start_Date) Then MsgBox "Please include time"

  • Thread starter Thread starter JethroUK©
  • Start date Start date
J

JethroUK©

I'm am trying to trap people typing in a date without a time (appointment)
except the whole appointment has been deleted (Null)

Tried:
If (Start_Date = Int(Start_Date)) And Not IsNull(Start_Date) Then MsgBox
"Please include time"

....but i'm not getting the right response, so can you check my syntax?
 
Try:

If (Nz(Start_Date,0) = Int(Nz(Start_Date,0))) Then MsgBox "Please include
time"
 
tried that, but it still pops the question if the field is null (didn't
explain this v. well in my post) - the time bit seemed to work until i tried
to compound it with the 'not null' part & that's the bit i seem to be
struggling with

tried all combinations & finally ended up:

If IsNull(Start_Date) = False And (Start_Date = Int(Start_Date)) Then

which eventually seemed to cover both conditions

thanks
 
JethroUK© said:
I'm am trying to trap people typing in a date without a time (appointment)
except the whole appointment has been deleted (Null)

Tried:
If (Start_Date = Int(Start_Date)) And Not IsNull(Start_Date) Then MsgBox
"Please include time"


Try this:

If TimeValue(Nz(Start_Date,#0:0#)) = 0 Then
 
Oh. In other words, you don't want to prompt if no date has been supplied.

You could use something like

If (Nz(Start_Date,0.123) = Int(Nz(Start_Date,0))) Then MsgBox "Please
include

or

If TimeValue(Nz(Start_Date,#1:02:03#)) = 0 Then

(the actual value you put in the first Nz function isn't critical, as long
as it's non-zero)
 
i'll give that a try thanks

Douglas J Steele said:
Oh. In other words, you don't want to prompt if no date has been supplied.

You could use something like

If (Nz(Start_Date,0.123) = Int(Nz(Start_Date,0))) Then MsgBox "Please
include

or

If TimeValue(Nz(Start_Date,#1:02:03#)) = 0 Then

(the actual value you put in the first Nz function isn't critical, as long
as it's non-zero)
 
Back
Top