Reputation: 459
I have a contacts database in Microsoft Access with all of the data in one table. I'm trying to create a report that groups the users by 'status' and I'm having trouble trying to determine how to do this.
Each contact has two fields, Status 1 and Status 2. Status 1 can be null, A or B and Status 2 can be either true or false.
The report should group them something like this:
Status 1 Null
Contact name and details (repeated for every contact with this status)
Status 1 A
Contact name and details (repeated for every contact with this status)
Status 1 B
Contact name and details (repeated for every contact with this status)
Status 2 True
Contact name and details (repeated for every contact with this status)
There is going to be some overlap with these statuses as some records match more than one status, but that's fine. Showing duplicates on this page is perfectly acceptable.
If this were a web app, I would simply write 4 queries and loops through the resulting record set, displaying the results under each appropriate header. But in an Access report I cannot figure out what to do.
Thanks!
Upvotes: 0
Views: 1204
Reputation: 91356
You might consider basing your report in a UNION query:
SELECT 1 As SortOrder, Contact, Details, Status1, Status2 FROM ContactsTable
WHERE Status1 Is Null
UNION ALL
SELECT 2 As SortOrder, Contact, Details, Status1, Status2 FROM ContactsTable
WHERE Status1 = "A"
UNION ALL
SELECT 3 As SortOrder, Contact, Details, Status1, Status2 FROM ContactsTable
WHERE Status1 = "B"
UNION ALL
SELECT 4 As SortOrder, Contact, Details, Status1, Status2 FROM ContactsTable
WHERE Status2 = True
Upvotes: 1