Validate Field

H

Hayzarat

Help. I'm trying to validate a field in a form. I've used input mask to get
the right numbers and letters. But I need to validate the numbers and
letters.
Basically its made up of 6 numbers then 4 letters and finally 2 numbers.
ie 121456ZJAN08
the first two numbers must be between 01 and 31 ie 12 (day of month)
the next 4 numbers must be a 24hr time ie 1456 (0001 to 2359)
the Z remains the same all the time
the letters are the month ie JAN
the last 2 numbers the year.
Any help on this I will be very grateful
 
K

KARL DEWEY

Why not use a standard DateTime field formatted like this ---
UCase(Format([YourDateField],"ddhhnn\Zmmmyy"))
 
H

Hayzarat

Sorry for being stupid where would I use this?

KARL DEWEY said:
Why not use a standard DateTime field formatted like this ---
UCase(Format([YourDateField],"ddhhnn\Zmmmyy"))
--
KARL DEWEY
Build a little - Test a little


Hayzarat said:
Help. I'm trying to validate a field in a form. I've used input mask to get
the right numbers and letters. But I need to validate the numbers and
letters.
Basically its made up of 6 numbers then 4 letters and finally 2 numbers.
ie 121456ZJAN08
the first two numbers must be between 01 and 31 ie 12 (day of month)
the next 4 numbers must be a 24hr time ie 1456 (0001 to 2359)
the Z remains the same all the time
the letters are the month ie JAN
the last 2 numbers the year.
Any help on this I will be very grateful
 
K

KARL DEWEY

You would use a datatype of DateTime field in your table, not text, and use
what I posted in your forms and report to display the date in your desired
format.

The advantage to using a standard DateTime field is that it will be easy to
perform date functions later instead of trying to parse your text information
and then construct a date that Access can use in functions.
--
KARL DEWEY
Build a little - Test a little


Hayzarat said:
Sorry for being stupid where would I use this?

KARL DEWEY said:
Why not use a standard DateTime field formatted like this ---
UCase(Format([YourDateField],"ddhhnn\Zmmmyy"))
--
KARL DEWEY
Build a little - Test a little


Hayzarat said:
Help. I'm trying to validate a field in a form. I've used input mask to get
the right numbers and letters. But I need to validate the numbers and
letters.
Basically its made up of 6 numbers then 4 letters and finally 2 numbers.
ie 121456ZJAN08
the first two numbers must be between 01 and 31 ie 12 (day of month)
the next 4 numbers must be a 24hr time ie 1456 (0001 to 2359)
the Z remains the same all the time
the letters are the month ie JAN
the last 2 numbers the year.
Any help on this I will be very grateful
 
H

Hayzarat

Karl thanks for your fast response. I totally understand what you mean by
changing it to a DateTime field, this will help me out later in my build. But
now I keeping invalid entry error come up. Even when I enter the data
straight into the table. My input mask is 000000\Z>LLL00, also my keypress is
set to change to uppercase.

KARL DEWEY said:
You would use a datatype of DateTime field in your table, not text, and use
what I posted in your forms and report to display the date in your desired
format.

The advantage to using a standard DateTime field is that it will be easy to
perform date functions later instead of trying to parse your text information
and then construct a date that Access can use in functions.
--
KARL DEWEY
Build a little - Test a little


Hayzarat said:
Sorry for being stupid where would I use this?

KARL DEWEY said:
Why not use a standard DateTime field formatted like this ---
UCase(Format([YourDateField],"ddhhnn\Zmmmyy"))
--
KARL DEWEY
Build a little - Test a little


:

Help. I'm trying to validate a field in a form. I've used input mask to get
the right numbers and letters. But I need to validate the numbers and
letters.
Basically its made up of 6 numbers then 4 letters and finally 2 numbers.
ie 121456ZJAN08
the first two numbers must be between 01 and 31 ie 12 (day of month)
the next 4 numbers must be a 24hr time ie 1456 (0001 to 2359)
the Z remains the same all the time
the letters are the month ie JAN
the last 2 numbers the year.
Any help on this I will be very grateful
 
K

Ken Sheridan

I don't think you do quite understand what Karl is suggesting here. The data
is entered in a conventional date/time format. Taking your example, the
value might be entered internationally unambiguously as:

2008-01-12 14:56

You can then return the formatted value in a computed column in a query, or
a computed control on a form or report using the expression
UCase(Format([YourDateField],"ddhhnn\Zmmmyy")) which Karl gave you.

By using a column of date/time data type it is in effect self-validating, as
only a valid date/time value will be accepted.

Ken Sheridan
Stafford, England

Hayzarat said:
Karl thanks for your fast response. I totally understand what you mean by
changing it to a DateTime field, this will help me out later in my build. But
now I keeping invalid entry error come up. Even when I enter the data
straight into the table. My input mask is 000000\Z>LLL00, also my keypress is
set to change to uppercase.

KARL DEWEY said:
You would use a datatype of DateTime field in your table, not text, and use
what I posted in your forms and report to display the date in your desired
format.

The advantage to using a standard DateTime field is that it will be easy to
perform date functions later instead of trying to parse your text information
and then construct a date that Access can use in functions.
--
KARL DEWEY
Build a little - Test a little


Hayzarat said:
Sorry for being stupid where would I use this?

:

Why not use a standard DateTime field formatted like this ---
UCase(Format([YourDateField],"ddhhnn\Zmmmyy"))
--
KARL DEWEY
Build a little - Test a little


:

Help. I'm trying to validate a field in a form. I've used input mask to get
the right numbers and letters. But I need to validate the numbers and
letters.
Basically its made up of 6 numbers then 4 letters and finally 2 numbers.
ie 121456ZJAN08
the first two numbers must be between 01 and 31 ie 12 (day of month)
the next 4 numbers must be a 24hr time ie 1456 (0001 to 2359)
the Z remains the same all the time
the letters are the month ie JAN
the last 2 numbers the year.
Any help on this I will be very grateful
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top