473,473 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Query Based on Selection Using a Checkbox

11 New Member
I have a database that tracks design changes made by different groups of people who work for different managers. I currently have a form setup such that the user can select a range of dates and when clicking a button to view the report, the report only shows the data within the selected date range.

I'd like to add the functionality that the user can check a box next to a single manager or multiple manager names and the report will display the data in the specified date range and for only the managers selected. I've been able to get the report and form to work for a single manager, but I can't seem to figure out how to get it to work for all the managers.

For a single manager, in the query I have the "manager" field criteria set to [txtmanager] where [txtmanager] is something the user selects. I thought about trying to have several checkboxes (one for each manager) on my form and then have some sort of IF statement that IF the checkbox was checked, then [txtmanager] = manager1. For multiple managers I thought I might be able to do somelike with AND statements.

Is this the correct way to try to do this and how would I go about doing it?
May 31 '07 #1
1 2954
MMcCarthy
14,534 Recognized Expert Moderator MVP
You can use VBA code to do this dynamically. Remove the criteria of the form dates and the manager from the query and use VBA code to create the criteria instead. Forget the Checkbox and create a combobox of mangers instead (cboManger).

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim strDocName As String
  3. Dim strLinkCriteria As String
  4.  
  5.     strDocName = "Your Report Name"
  6.     strLinkCriteria = "([DateField] BETWEEN #" & txtDateFrom & "# AND #" & txtDateTo & "#)"
  7.  
  8.     If nz(Me!cboManger, "") <> "" Then ' If manger is selected
  9.        strLinkCriteria = strLinkCriteria & " AND ([Manager]='" & Me!cboManager & "')"
  10.  
  11.     DoCmd.OpenReport strDocName, , , strLinkCriteria
  12.  
Jun 1 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: DebbieG | last post by:
I have a form based on this query: SELECT Students.LastSerDT, OtherInfo.Served, OtherInfo.HSGradYr, OtherInfo.ActivePart, OtherInfo.Served, Students.SSN, & ", " & & " " & AS Name,...
13
by: John young | last post by:
I have been looking for an answer to a problem and have found this group and hope you can assist . I have been re doing a data base I have made for a car club I am with and have been trying to...
3
by: Matthew | last post by:
I am trying to build a form that has certain criteria on it (combo boxes) which a user can pick from a range of values to specify the criteria he wants when he runs a query on the form. I am...
0
by: starace | last post by:
I have designed a form that has 5 different list boxes where the selections within each are used as criteria in building a dynamic query. Some boxes are set for multiple selections but these list...
3
by: hmiller | last post by:
Hey everyone, I am having a hell of a time trying to set this menu system up. Here's what I'm trying to do. Combo Box One; is populated by names under properties "row source" "Phase 1"...
4
by: The.Daryl.Lu | last post by:
Hi, Have a bit of a problem... I've created a form in Access and will use the form for a user to query a table based on the selected fields. The problem lies in that I was using checkboxes for...
1
by: inamul | last post by:
I want to select CheckBox based on data retrieved from mysql database table. Could anyone show me the simple way of doing it. Data store in table under colum "sectionOfInterest" is shown below...
5
by: OldBirdman | last post by:
I am attempting to assign a .RowSource to a ListBox using an SQL statement. I want to build the SQL statement "On-the-Fly", based on values in several controls on the form. I would like to restrict...
1
by: StuartD | last post by:
I have a sub form that is populated based on the selection of a year from a combo box on the main form. I'm trying to add a second main form combo box for item category to further filter the sub...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.