Input box Date

  • Thread starter Thread starter Jim
  • Start date Start date
J

Jim

I want to do a query, using an input box to let the user
enter the date. However, instead of using / or - between
month day and year, I want to let the user type in as one
string like 12022004 and return corresponding dates.

Thanks
Jim
 
As far as I know this cannot be done without some manipulation. When you say
"Input Box" to you mean the input function or are you referring to using a query parameter?

I'll assume the latter.

Criteria: DateSerial(Right([For What Date],4), Left([For What Date],2),Mid([For
What Date],3,2))

And that is no guarantee that the date the user entered is valid. By the way, I
guessed that the input was in mmddyyyy form.

A better way to handle this would be to use a form for the input and reference
the control on the form. Then you could check the entry to make sure it would
return a valid date before your user tries to execute the query.

Check out this article for a detailed discussion on using a combobox. The same
idea can be used with a simple text control.
http://www.fontstuff.com/access/acctut08.htm
 
I want to do a query, using an input box to let the user
enter the date. However, instead of using / or - between
month day and year, I want to let the user type in as one
string like 12022004 and return corresponding dates.

Thanks
Jim

Then you'll have to write VBA code to parse the eight-digit string
into a date; Access will not recognize it as one.

Why the extra hassle of an input box? Might you be able to use a Form
with a textbox? The textbox could have an Input Mask of 00/00/0000;
the user could type eight digits, Access will fill in the slashes
without their hitting the slash key, and you can use a query criterion
of

=Forms!NameOfForm!NameOfTextbox

and not need to use any VBA code at all.

John W. Vinson[MVP]
 
Thank you John.

-----Original Message-----
As far as I know this cannot be done without some manipulation. When you say
"Input Box" to you mean the input function or are you
referring to using a query parameter?
I'll assume the latter.

Criteria: DateSerial(Right([For What Date],4), Left([For What Date],2),Mid([For
What Date],3,2))

And that is no guarantee that the date the user entered is valid. By the way, I
guessed that the input was in mmddyyyy form.

A better way to handle this would be to use a form for the input and reference
the control on the form. Then you could check the entry to make sure it would
return a valid date before your user tries to execute the query.

Check out this article for a detailed discussion on using a combobox. The same
idea can be used with a simple text control.
http://www.fontstuff.com/access/acctut08.htm
I want to do a query, using an input box to let the user
enter the date. However, instead of using / or - between
month day and year, I want to let the user type in as one
string like 12022004 and return corresponding dates.

Thanks
Jim
.
 
Thank you John.

-----Original Message-----


Then you'll have to write VBA code to parse the eight- digit string
into a date; Access will not recognize it as one.

Why the extra hassle of an input box? Might you be able to use a Form
with a textbox? The textbox could have an Input Mask of 00/00/0000;
the user could type eight digits, Access will fill in the slashes
without their hitting the slash key, and you can use a query criterion
of

=Forms!NameOfForm!NameOfTextbox

and not need to use any VBA code at all.

John W. Vinson[MVP]
.
 
Back
Top