Need some help here...
I am working in Access and have a query that gets selection criteria from a form with 6 selection options. I also want to be able to check for "all: in any of the 6 combo box criteria selections. Below is a query that might work but am not sure how to implement or if it is correct. -
SELECT tblContacts.CntSalutation, tblContacts.CntFirstName, tblContacts.CntLastName, tblContacts.CntMailAddr, tblContacts.CntStrAddr, tblContacts.CntCity, tblContacts.CntState, tblContacts.CntZip
-
FROM tblContacts INNER JOIN tlnkOrgCategories ON tblContacts.CntID = tlnkOrgCategories.OrgID
-
-
IF (([forms]![frmreports].[cat1] OR[forms]![frmreports].[cat2] Or [forms]![frmreports].[cat3] Or [forms]![frmreports].[cat4] Or [forms]![frmreports].[cat5] Or [forms]![frmreports].[cat6])) = "All"
-
THEN
-
WHERE (tlnkOrgCategories.OrgCategory) is not null
-
Else
-
WHERE
-
(((tlnkOrgCategories.OrgCategory)=[forms]![frmreports].[cat1]
-
Or (tlnkOrgCategories.OrgCategory)=[forms]![frmreports].[cat2]
-
Or (tlnkOrgCategories.OrgCategory)=[forms]![frmreports].[cat3]
-
Or (tlnkOrgCategories.OrgCategory)=[forms]![frmreports].[cat4]
-
Or (tlnkOrgCategories.OrgCategory)=[forms]![frmreports].[cat5]
-
Or (tlnkOrgCategories.OrgCategory)=[forms]![frmreports].[cat6]))
-
END IF
-
GROUP BY tblContacts.CntSalutation, tblContacts.CntFirstName, tblContacts.CntLastName, tblContacts.CntMailAddr, tblContacts.CntStrAddr, tblContacts.CntCity, tblContacts.CntState, tblContacts.CntZip
-
ORDER BY forms!frmreports.srt1;
-
I would appreciate info on how to implement, or is there a better way to select "all"?
Thanks!
PW
2 7745
Need some help here...
I am working in Access and have a query that gets selection criteria from a form with 6 selection options. I also want to be able to check for "all: in any of the 6 combo box criteria selections. Below is a query that might work but am not sure how to implement or if it is correct.
SELECT tblContacts.CntSalutation, tblContacts.CntFirstName, tblContacts.CntLastName, tblContacts.CntMailAddr, tblContacts.CntStrAddr, tblContacts.CntCity, tblContacts.CntState, tblContacts.CntZip
FROM tblContacts INNER JOIN tlnkOrgCategories ON tblContacts.CntID = tlnkOrgCategories.OrgID
IF (([forms]![frmreports].[cat1] OR[forms]![frmreports].[cat2] Or [forms]![frmreports].[cat3] Or [forms]![frmreports].[cat4] Or [forms]![frmreports].[cat5] Or [forms]![frmreports].[cat6])) = "All"
THEN
WHERE (tlnkOrgCategories.OrgCategory) is not null
Else
WHERE
(((tlnkOrgCategories.OrgCategory)=[forms]![frmreports].[cat1]
Or (tlnkOrgCategories.OrgCategory)=[forms]![frmreports].[cat2]
Or (tlnkOrgCategories.OrgCategory)=[forms]![frmreports].[cat3]
Or (tlnkOrgCategories.OrgCategory)=[forms]![frmreports].[cat4]
Or (tlnkOrgCategories.OrgCategory)=[forms]![frmreports].[cat5]
Or (tlnkOrgCategories.OrgCategory)=[forms]![frmreports].[cat6]))
END IF
GROUP BY tblContacts.CntSalutation, tblContacts.CntFirstName, tblContacts.CntLastName, tblContacts.CntMailAddr, tblContacts.CntStrAddr, tblContacts.CntCity, tblContacts.CntState, tblContacts.CntZip
ORDER BY forms!frmreports.srt1;
I would appreciate info on how to implement, or is there a better way to select "all"?
Thanks!
PW
Give this a try. SQL for queries in access use IIF -
SELECT tblContacts.CntSalutation, tblContacts.CntFirstName, tblContacts.CntLastName, tblContacts.CntMailAddr, tblContacts.CntStrAddr, tblContacts.CntCity, tblContacts.CntState, tblContacts.CntZip
-
FROM tblContacts INNER JOIN tlnkOrgCategories ON tblContacts.CntID = tlnkOrgCategories.OrgID
-
WHERE IIF([forms]![frmreports].[cat1]="All" OR
-
[forms]![frmreports].[cat2]="All" Or
-
[forms]![frmreports].[cat3]="All" Or
-
[forms]![frmreports].[cat4]="All" Or
-
[forms]![frmreports].[cat5]="All" Or
-
[forms]![frmreports].[cat6] = "All", tlnkOrgCategories.OrgCategory is not null,
-
tlnkOrgCategories.OrgCategory=[forms]![frmreports].[cat1]
-
Or (tlnkOrgCategories.OrgCategory)=[forms]![frmreports].[cat2]
-
Or (tlnkOrgCategories.OrgCategory)=[forms]![frmreports].[cat3]
-
Or (tlnkOrgCategories.OrgCategory)=[forms]![frmreports].[cat4]
-
Or (tlnkOrgCategories.OrgCategory)=[forms]![frmreports].[cat5]
-
Or (tlnkOrgCategories.OrgCategory)=[forms]![frmreports].[cat6])
-
GROUP BY tblContacts.CntSalutation, tblContacts.CntFirstName, tblContacts.CntLastName, tblContacts.CntMailAddr, tblContacts.CntStrAddr, tblContacts.CntCity, tblContacts.CntState, tblContacts.CntZip
-
ORDER BY forms!frmreports.srt1;
-
Got it working, I appreciate the help.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: jaysonsch |
last post by:
Hello!
I am having some problems with a database query that I am trying to do.
I am trying to develop a way to search a database for an entry and
then edit the existing values. Upon submit, the...
|
by: Dave |
last post by:
Hi all,
I've been trying to figure this out for the last day and a half and
it has me stumped. I've got a web application that I wrote that
keeps track of trading cards I own, and I'm moving it...
|
by: wiredog |
last post by:
I am struggling rewriting my query from MS Access' IIF, Then to SQL
Servers TSQL language. I am hoping some one can give me some
guidance. I believe I have the first portion of the query correct...
|
by: Robert Brown |
last post by:
suppose I have the following table:
CREATE TABLE (int level, color varchar, length int, width int, height
int)
It has the following rows
1, "RED", 8, 10, 12
2, NULL, NULL, NULL, 20...
|
by: Stefan V. |
last post by:
Hello!
I am trying to convert a query written for SQL Server 2000 database
tables, to a MS Access query.
Here is what I have in SQL Server:
SELECT t2.*,
CASE WHEN t2.QType = '3' THEN...
|
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...
|
by: JC Voon |
last post by:
Hi All:
I'm new in Threading and Web Services, can someone please verify my
code, i'm not sure whether this is the correct way, althought it is
partially work, but some time it will raise...
|
by: Sam Durai |
last post by:
Hello, I need to merge a small table (of rows less than 100,sometimes
even 0 rows) to a big table (of rows around 4 billion). I used the PK
of the big table as merge key but merge does a table scan...
|
by: tomlebold |
last post by:
Having problems displaying query results from combo boxes on a sub
form, which is on the same form that is used to select criteria.
This has always worked form me when displaying query results on...
|
by: RCapps |
last post by:
When running the below SQL Query I keep getting the following error:
Server: Msg 4924, Level 16, State 1, Line 1
ALTER TABLE DROP COLUMN failed because column 'ContractDef' does not exist in table...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |