473,385 Members | 1,486 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,385 software developers and data experts.

Access query help - results as string or list

I have created a query in MS Access 2003 that is pulling training records for our company that includes training hour calculation. One field I am pulling is the instructor name. Many courses have multiple instructors, which means I am getting multiple records for a single course. I need to capture all of the instructor names, but I only want a single record for each course due to the hour calculation. I would like the report to generate only one record per unique course but would like all of the instructor names to appear in a single field as a list. I am sure there is a way to do this, but I am not sure how. A coworker suggested it has to do with how I group. It is the R.LASTNAME that I would like to list in 1 field. Here is the query I am using:

SELECT Left(I.LEARNINGACTIVITYCODE,3) AS CATEGORY, I.LEARNINGACTIVITYTITLE, I.LEARNINGACTIVITYCODE, I.CODE, I.STARTDATE, I.ENDDATE, I.UNITS, Count(T.ENROLLMENTSTATUS) AS COMPLETED, I.UNITS*Count(T.ENROLLMENTSTATUS) AS HOURS, Format(I.UNITS*Count(T.ENROLLMENTSTATUS)/8, "000.000") AS DAYS, T.ENROLLMENTSTATUSDESCR, T.STUDENTCOMMENTS, N.INSTRUCTORID, R.LASTNAME AS INSTRUCTOR
FROM LMS650_DRLAINSTANCEFULL AS I, LMS650_DRLATRANSCRIPTALT AS T, LMS650_DRLAIINSTRUCTORMAP AS M, LMS650_DRLAINSTANCEFULLINSTRUCTORS AS N, LMS650_DRRESOURCEFULL AS R

WHERE (((( I.LEARNINGACTIVITYID=T.LEARNINGACTIVITYID) AND I.LEARNINGACTIVITYCODE=T.LACODE) AND I.CODE=T.INSTANCECODE) AND T.LEARNINGACTIVITYINSTANCEID=M.LEARNINGACTIVITYINS TANCEID) AND ((M.INSTRUCTORID=N.INSTRUCTORID) AND N.INSTRUCTORID=R.INSTRUCTORID) AND I.LEARNINGACTIVITYCODE Like 'ODI%' AND (( I.STARTDATE) >= #1/1/2007#) AND (( I.STARTDATE) < #11/1/2007#) AND ((I.STATUS)='A') AND T.ENROLLMENTSTATUS='C' AND T.ENROLLMENTSTATUSDESCR='Completed'

GROUP BY I.LEARNINGACTIVITYTITLE, I.LEARNINGACTIVITYCODE, I.CODE, I.STARTDATE, I.ENDDATE, I.UNITS, I.ENROLLEDCOUNT, T.ENROLLMENTSTATUS, T.ENROLLMENTSTATUSDESCR, T.STUDENTCOMMENTS, N.INSTRUCTORID, R.LASTNAME
ORDER BY I.LEARNINGACTIVITYCODE, I.CODE, I.LEARNINGACTIVITYTITLE, I.STARTDATE DESC;

Thank you for any suggestions.
Nov 6 '07 #1
3 1676
JustJim
407 Expert 256MB
I have created a query in MS Access 2003 that is pulling training records for our company that includes training hour calculation. One field I am pulling is the instructor name. Many courses have multiple instructors, which means I am getting multiple records for a single course. I need to capture all of the instructor names, but I only want a single record for each course due to the hour calculation. I would like the report to generate only one record per unique course but would like all of the instructor names to appear in a single field as a list. I am sure there is a way to do this, but I am not sure how. A coworker suggested it has to do with how I group. It is the R.LASTNAME that I would like to list in 1 field. Here is the query I am using:

SELECT Left(I.LEARNINGACTIVITYCODE,3) AS CATEGORY, I.LEARNINGACTIVITYTITLE, I.LEARNINGACTIVITYCODE, I.CODE, I.STARTDATE, I.ENDDATE, I.UNITS, Count(T.ENROLLMENTSTATUS) AS COMPLETED, I.UNITS*Count(T.ENROLLMENTSTATUS) AS HOURS, Format(I.UNITS*Count(T.ENROLLMENTSTATUS)/8, "000.000") AS DAYS, T.ENROLLMENTSTATUSDESCR, T.STUDENTCOMMENTS, N.INSTRUCTORID, R.LASTNAME AS INSTRUCTOR
FROM LMS650_DRLAINSTANCEFULL AS I, LMS650_DRLATRANSCRIPTALT AS T, LMS650_DRLAIINSTRUCTORMAP AS M, LMS650_DRLAINSTANCEFULLINSTRUCTORS AS N, LMS650_DRRESOURCEFULL AS R

WHERE (((( I.LEARNINGACTIVITYID=T.LEARNINGACTIVITYID) AND I.LEARNINGACTIVITYCODE=T.LACODE) AND I.CODE=T.INSTANCECODE) AND T.LEARNINGACTIVITYINSTANCEID=M.LEARNINGACTIVITYINS TANCEID) AND ((M.INSTRUCTORID=N.INSTRUCTORID) AND N.INSTRUCTORID=R.INSTRUCTORID) AND I.LEARNINGACTIVITYCODE Like 'ODI%' AND (( I.STARTDATE) >= #1/1/2007#) AND (( I.STARTDATE) < #11/1/2007#) AND ((I.STATUS)='A') AND T.ENROLLMENTSTATUS='C' AND T.ENROLLMENTSTATUSDESCR='Completed'

GROUP BY I.LEARNINGACTIVITYTITLE, I.LEARNINGACTIVITYCODE, I.CODE, I.STARTDATE, I.ENDDATE, I.UNITS, I.ENROLLEDCOUNT, T.ENROLLMENTSTATUS, T.ENROLLMENTSTATUSDESCR, T.STUDENTCOMMENTS, N.INSTRUCTORID, R.LASTNAME
ORDER BY I.LEARNINGACTIVITYCODE, I.CODE, I.LEARNINGACTIVITYTITLE, I.STARTDATE DESC;

Thank you for any suggestions.
You are not (easily) going to get a query to do what you want. What you need to do is make sure your query is gathering all the required records (which it sounds like it is) and use that query as the record source for either a form or a report and do the grouping on the form or report. Yell for help if you need it!

Jim
Nov 7 '07 #2
Thank you for the help. I will take that approach since my final output is a report.
Nov 7 '07 #3
JustJim
407 Expert 256MB
Thank you for the help. I will take that approach since my final output is a report.
No worries Mate!

JIm
Nov 8 '07 #4

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

Similar topics

0
by: david liu | last post by:
access 2000 query: here's what i want to do. from an asp page, perform a search on a table in access. i have used sql code in the asp page itself, but i'd rather execute a query in access. i...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
4
by: Sami | last post by:
I hope someone will tell me how to do this without having to do any VB as I know nothing in that area. I am a rank beginner in using Access. I have created a database consisting of student...
2
by: Alicia | last post by:
If I wanted to create a table by hand create table temp( etc, where do I do it in access?
1
by: tina.boroff | last post by:
I have 3 boxes that essentially use the same code for not in List events (Thank you to David for all of your help on that one). The code opens another form if the user wants to enter data that is...
2
by: Robert Smith jr. | last post by:
Hello, Please pardon my newbie question ... I am building an ASP.NET page that displays a recordset with a Delete statement enabled (this all works fine). I want to Insert the current row...
7
by: nemo | last post by:
Try to explain this as simple as I can - User provides a list (names, ID's, or ....) into a text box on a GUI application... Based on which options they select I have to look up the...
0
by: Chuck36963 | last post by:
Hi all, I've been working on a listing problem and I can't figure out how to work it out. I have looked far and wide on the web to find answers, but I'd like other peoples input on my project in...
5
by: PHPBABY3 | last post by:
Hi, 1. I have two SQL tables. I will call them employees and departments: EMP: LAST_NAME, FIRST_NAME, DEPTNM DEPT: NUM, NAME Input: text string FIND Output: the LAST_NAME, FIRST_NAME...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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 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.