inputmask

  • Thread starter Thread starter Jean-Paul
  • Start date Start date
J

Jean-Paul

Hi,
I have this field where I want the user to enter a arrival time.

As an imput mask I wrote 00:00

Indeed this forces the user to enter something like 10:30, but when I
use following code:

aan = Left(Me!Aankomen, 3)

I get 103 instead of 10:

What to do?

Also is there a way to force a user to only use 00 or 30 as the last 2
characters?

Thanks
 
Hi Jean-Paul,

Is the underlying field a date field? If not, it should be. Date
fields are really date and time fields. They can store dates, times or dates
and times. The actual value that is stored an real number offset from
December 30, 1899 with the whole portion (+ or -) indicating days and the
fractional part indicating time. A date without a time is actually that date
with a time of 12:00 midnight. A time without a date is actually that time
on December 30, 1899. If you have an arrival date field, just use that to
hold both the date and time instead of a separate fields. If you do not have
an arrival date and the arrival time is a date field, you can set the field's
format to Short Time and get rid of the Input Mask. Then to get the hour you
would do:

aan = Hour(Aankomen)

If you have a combined date/time of arrival field set its format to
something like "mm/dd/yyyy hh:nn". To get the hour, you would still do the
same thing.

To enforce the entry of 0 or 30 minutes you can use the field's Before
Update event. Check to see if Minute(Aankomen) is 0 or 30. If not cancel
the event.

Private Sub Aankomen_BeforeUpdate(Cancel As Integer)

If Minute(Aankomen) <> 0 And Minute(Aankomen) <> 30 Then
MsgBox "Please enter only zero or thirty minutes."
Cancel = True
End If

End Sub

Hope that helps,

Clifford Bass
 
Jean-Paul said:
Hi,
I have this field where I want the user to enter a arrival time.

As an imput mask I wrote 00:00

Indeed this forces the user to enter something like 10:30, but when I
use following code:

aan = Left(Me!Aankomen, 3)

I get 103 instead of 10:

What to do?

Also is there a way to force a user to only use 00 or 30 as the last 2
characters?

A mask does not, of necessity store the mask. You can use the mask wizard to
determine how the values are stored

You can force 00 or 30 in code but I would either use a combobox to present
the values with the ":" in place or use two fields, one for the hour and the
other which only allows 00 or 30 (A click event can be used to switch
between the two)

However Clifford's point are valid if you want to use this as an actual
time.
 
Thanks for your reply..
But...; and this is dumb, I know, I MUST stick with a textfield... so no
time field...

So my question again... how about the input mask and getting the :

Sorry
JP
 
Hi Jean-Paul,

In that case.... As Mike notes, the colon in the mask is not stored.
Which is why aan = Left(Me!Aankomen, 3) gives you the 103. Use 2 instead of
3. And to enforce the 00 or 30 minutes, I do not think one could define a
mask that would enforce that. So, check the value of Right(Aankomen, 2) for
"00" or "30" in the Before Update event.

Clifford Bass
 
Back
Top