Ron J
07-17-2009, 10:43 AM
I have read a bunch of the posts concerning formating queries. It appeared that most are geared toward the end result and not the user input. So...can a sort of input mask be used when prompting a user for input in a query? This concerns the inputting of dates. At present the input is a simple:
Between [Start Date] and [End Date]
If you enter ##/##/#### or ##/##/## the information I am hoping for is returned. If you enter ###### or ######## then you get nothing. How do I get the /'s?
I am beginning to think that finding the Loch Ness monster and Big Foot would be easier than tangling with an Access query.
boblarson
07-17-2009, 10:45 AM
No, you cannot do this with a parameter prompt in a query. You really should use a FORM for input for queries/reports and not do the [Enter Something] in queries.
Using a form you can do all that you want.
Ron J
07-17-2009, 10:48 AM
Man, that was a fast reply. Thanks for your help. I will try the FORM route.
Take care
Ron J
07-17-2009, 11:52 AM
boblarson:
I took your advice and attempted using a FORM. I used an expression builder to execute upon the clicking of a button. It is not working how I had hoped. Here is how I am attempting to determine what employees were hired during a user defined time period:
tblEmployees - contains employee information (first name, last name, date of birth, hire date, etc.)
formEmployeeHirePeriod
txtEmpStartHirePeriod - user enters a date
txtEmpEndHirePeriod - user enters a date
toggleHirePeriod - executes expression below upon being clicked
Using the expression builder I entered:
FROM tblEmployees
WHERE (((tblEmployees.DateHired) Between [txtEmpStartHirePeriod] and [txtEmpEndHirePeriod]))
ORDER BY tblEmployees.DateHired
boblarson
07-17-2009, 12:08 PM
If this is in the query you need to also tell it which form this is on:
WHERE (((tblEmployees.DateHired) Between [Forms]![YourFormNameHere]![txtEmpStartHirePeriod] and [Forms]![YourFormNameHere]![txtEmpEndHirePeriod]))
Ron J
07-25-2009, 06:33 AM
Thanks again for your assistance. boblarson for President 2012!