473,395 Members | 1,986 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Handling checkboxes in Access Report

Hi, I am creating a report in Access, where the users select checkboxes & they get the required data from table in the report. Below is the sql statement i have written:
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM tblMain
  3. WHERE (((tblMain.[Column1]) LIKE[forms]![SearchReports]![Option1] & "*") AND ((tblMain.[Column2]) LIKE[forms]![SearchReports]![Option2] & "*") AND ((tblMain.[Column3]) LIKE[forms]![SearchReports]![Option3] & "*") AND ((tblMain.[Column4]) LIKE[forms]![SearchReports]![Option4] & "*"));
  4.  
The SQL query works perfect if we select/check e.g. one Option only..however if I select Option 1 & 2 both, it doesn't display records, whereas I have records for both the options my table. If I use OR operator in my SQL query, it displays all records of table, regardless of whether they were CHECKED or not . any help would be appreciated as I can't see how to configure it. Thks.
Attached Images
File Type: jpg chkboxes.jpg (6.0 KB, 349 views)
Aug 16 '09 #1
9 3520
Anyone please? would appreciate suggestions.Thxs.
Aug 17 '09 #2
ChipR
1,287 Expert 1GB
What are you trying to compare with the LIKE operator?
Aug 17 '09 #3
Column 1, 2,3 & 4 are YES/NO fields in my table. And in my sql statement,
Expand|Select|Wrap|Line Numbers
  1. ((tblMain.[Column1]) LIKE[forms]![SearchReports]![Option1])
Option1, 2,3 & 4 are the names of my checkboxes on the search form. if I check the checkbox for Option 1, then it gives all record from column 1 on my report, like wise if I select OPTION 1 & 2 both on the form, then no record is displayed in the report, coz i am using the AND operator. But If i use OR instead of AND in the sql statement, then if I select OPTION 1 only, all the records related to OPTION 1,2 ,3 & 4 are displayed.

So basically I only want records on my report whose checkboxes are selected by me on the form. I hope i haven't confused you here..thxs for your help.
Aug 17 '09 #4
ChipR
1,287 Expert 1GB
Should the records returned match all of the check boxes, or do you want the records who have true values for the options that you checked, regardless of the other fields?
Aug 17 '09 #5
I only want records who have true values for the options that I checked. E.g. If I select checkbox 1 & 2 (Option 1& 2 on my form), so the REPORT should display all records for these 2 options & ignore OPTION 3 & 4 (since i didn't check them on form).
Thxs.
Aug 17 '09 #6
ChipR
1,287 Expert 1GB
In that case, you need to test the values of the check boxes, like:
WHERE
(Column1 = True OR Option1 = False)
AND
(Column2 = True OR Option2 = False)
AND
(Column3 = True OR Option3 = False)
AND
(Column4 = True OR Option4 = False)

Hopefully, that makes sense. If the check box on the form is True, then the value in the column must be true. Otherwise, it doesn't matter. I left out the Form references just to keep it shorter.
Aug 17 '09 #7
Hi ChipR, can you please write the exact sql statement for me? I haven't understood properly what you are saying here. Thxs
Aug 17 '09 #8
ChipR
1,287 Expert 1GB
This depends on the value that you have set your yes/no fields to save in your table. In design view for your table, look at one of the fields and its Format option on the General tab. I have mine set to True/False, so I'll compare the field value to True. Now, it turns out the value of the check box might be Null, so we have to check for that:
Expand|Select|Wrap|Line Numbers
  1. SELECT * 
  2. FROM tblMain 
  3. WHERE
  4. ([column1] = True OR (Forms!SearchReports!Option1 <> -1) OR Forms!SearchReports!Option1 IS NULL)
  5. AND
  6. ([column2] = True OR (Forms!SearchReports!Option2 <> -1) OR Forms!SearchReports!Option2 IS NULL)
  7. AND
  8. ([column3] = True OR (Forms!SearchReports!Option3 <> -1) OR Forms!SearchReports!Option3 IS NULL)
  9. AND
  10. ([column4] = True OR (Forms!SearchReports!Option4 <> -1) OR Forms!SearchReports!Option4 IS NULL)
Basically, the condition is: If the check box is null, that field doesn't have to be true, OR if the check box is false (-1), that field doesn't have to be true. OR the field has to be true.
Aug 17 '09 #9
Thxs ChipR..it works great..really appreciate your help.
Cheers.
Aug 17 '09 #10

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

Similar topics

8
by: DylanM | last post by:
I have some checkboxes that are generated from the results of a database search. At the moment, the checkboxes are part of a table making up a form. Users are going through the form, clicking the...
2
by: Incolor | last post by:
Hello All! I have to generate a checklist form as an input form in Access. A paper form is taken out in the field and checked yes, no, OR n/a for each item inspected. The problem I am having is...
3
by: EHameed | last post by:
Hello Everyone, Im a new member in this GREAT forum. My question is: I have a simple database that contains many checkboxes and in the Report i want to show only the checked CheckBoxes for...
0
by: Lysander | last post by:
Thought I would give something back with a few articles. This article is a bit of code to add error handling. When I have time, I want to write articles on multilingual databases, and Access...
0
by: krokador | last post by:
This is doing my head in... We're starting to migrate our report-printing and such (forms included) to pdf - using xml files and nFOP with asp.net. In this case I have to print out a form which...
2
by: GISmatters | last post by:
I have unbound checkboxes in a nested gridview to allow multi-selection of "child" rows. For context, the parent gridview rows are for large "reports", the child rows are for various specific files...
1
WyvsEyeView
by: WyvsEyeView | last post by:
I have a report on which each record could potentially display three checkboxes...call them chk1, chk2, chk3. To minimize clutter on the page, I only want to display the labels of the checkboxes that...
14
by: zufie | last post by:
I have to create a QA report regarding callers calling into a phone hotline. The report consists of many checkboxes such as: Did the IBCCP agency contact you? Yes/NO How many days passed...
13
by: curious80237 | last post by:
In Access 2003: A table with four yes/no fields is part of a query used as data source for a report. The yes/no fields show in the datasheet and the report as checkboxes; the default value of the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.