Text Box containing date

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

Guest

I have 2 unbound text boxes in my form which have start date and end date.
This form is feeding parameters to a query. I have set the input mask of each
of these 2 boxes to Short Date format and set a validation rule for the end
Date such that it is >=[Start date]. It shows the mask in both boxes but the
cursor is displaced very far to the right in the End Date box . How can I
bring to the left edge of this box just as in Start Box. Also the validation
rule is not working. For example, it doesn't display any validation text even
when start date =06/02/2005 and end date = 06/01/2005. Why?
 
Neeraj,

Hi from the UK.

I confess to hating both input masks and validation rules (because they gave
me no end of problems!), so to achieve what you want I'd take a different
route. Maybe you'd like to give this a try:

(1) remove the masks from the two date fields, but set the data format as
short date.

(2) add a simple validation process to the 'on lose focus' event of the end
date. This could be something like:

if isnull(me!startdate) then exit sub
if isnull(me!enddate) then exit sub
if me!enddate<me!startdate then
msgbox("End date cannot be before start date!")
me!enddate=null
me!enddate.setfocus
end if

(If you sometimes enter the end date first you might want to put a modified
version of this validation onto the on lose focus event of the start date
field)

Now, just a thought: not knowing where you're from, is your short date
format day-month-year (as in UK) or month-day-year (as in USA)? In some
contexts, whatever you specify, Access (especially some VBA processes) will
ALWAYS interpret a date as month-day-year, and maybe this was causing the
validation to fail.

Is this helpful?
 
Back
Top