The
easiest way would be to hire someone to do it for you
Short of that, there's a couple of approaches you could take and it really depends on how familiar you are with vba as to which I would recommend for you.
Essentially the problem boils down to this: there are up to four different queries that might need to respond to the search options your user might choose.
1. All shifts - one date (Select ... Where Date=Whatever)
2.one shift-one date (Select...Where Shift=<whatever> AND Date = <whatever>)
3.All shifts - range of dates (Select...WHERE Date Between StartDate and EndDate)
4.One shift-range of dates (Select...WHERE Shift = <whatever> AND Date Between StartDate and Enddate)
Also, consider whether you might want to allow the user to select 2 out of the three available shifts?
There's another 2 queries to add if so:
5. 2 shifts, OneDate (Select...WHERE Shift In (<whatever>,<another>) and Date =<whatever>)
6. 2 shifts, Range of dates (Select...WHERE Shift In (<whatever>,<another>) and Date Between Startdate AND Enddate)
As you can see....the where clause of the query changes radically depending on exactly what you want to see.
You could handle this situation in two ways:
___________________________________________________
A. Build a saved query for each possible permutation that you want to allow for and then use vba in the on_click event of your 'Get Results' button to choose which query/report to open.
___________________________________________________
B. You can build a SQL query dynamically using vba in the on_click event of the 'Get Results' button. Then you open this single query or use it as the basis for the report that the user sees. If you go down this path you will need to learn about
concatenation of strings (especially note the difference in using the '&' versus using the '+' operators when adding items where one side might be a null). You'll also need to learn about using
querydefs.
Also, if you plan to allow the user to choose 'All' shifts, or any combination of shifts that they like, you'll need to learn about using unbound
multiselect listboxes. There are
sample databases on this forum that illustrate how to add an 'All' option to the list of available shifts. If you search, there are also samples of code showing how to use the multiselect
listbox to build a
dynamic query based on which items are selected. Post 2 in this
thread shows some code that does exactly that (Remembering the your query would be a
Select query, not an Append query as shown in that example). You would need to modify this code to deal with your situation but this shows the general principles that you will need to use. (There's also a sample db
here that produces a similar result by building a
where clause to use as an argument in the docmd.openreport command).
_________________________________________________
Although you may be tempted to take the first option since it probably looks simpler consider how your db is going to start getting cluttered up with all the queries and reports that you'll need to make. If you ever need to make changes to the output, you're going to have to make those changes in every variation on the queries. The alternative requires changes in just one place. You also won't learn as much
I've bolded a few of the key words you should search for to learn more about various topics that are relevant to your problem.
Why don't you do some searching/reading and decide what approach you want to take. Then post back with your best effort. If you have trouble sorting it all out, then post a zipped copy of your db (strip out any sensitive data but leave enough to work with (or some dummy data) for testing purposes). I'd be happy to have a look and help you in the right direction.