Checking Time Field

jake7363

Registered User.
Local time
Today, 13:09
Joined
Mar 14, 2005
Messages
46
Hello,
I am having a bit of a problem trying to set up a message box.
I have a date field and a time field as the last two fields on my form (continuous). I would like a message box to display if the time field (formatted "medium time") is left empty. It must be filled out to complete the record.

I am unable to use the "required" attribute, because the all of the data is not available right away, so the user would have to leave the record and come back to it.

Once the date is completed, I set the focus on the time. The problem is that I set up an "If" statement for "Lost focus" but nothing happens. I tried to use the conditions of "=0" and "", with neither working. Again, I am using the Medium time format.

Below is an abbreviated sampling of the code:
If txtjobEndTime.Value = 0 Then
msgbox "Time must be entered to complete record", vbOKOnly, "Error!"
End If

Any help will be appreciated.

Thanks,
Jake
 
If IsNull(txtjobEndTime) or (txtjobEndTime="") Then
 
Worked like a charm! Many thanks!!
jake
 
If IsNull(txtjobEndTime) or (txtjobEndTime="") Then

More efficient code (and easier way to type) is:

If txtjobEndTime & "" = "" Then

It gets rid of a function call, removes a logical operation and performs only one search. It is easier for the computer to combine the data and check it once, then check two different conditions. With computers these days you will more than likely not notice an effect, but it still does the same effect and takes less space.
 

Users who are viewing this thread

Back
Top Bottom