ms access create report with two tables - ms-access

I am needing to create a report between two tables. One table has ID, FirstName, LastName. The seconded table has NoteID, ID and Notes. There is a one to many relationship. Each person can have many notes. What I would like to do is fill a listbox or textbox with the notes that belong to that person.
On that note, how can I create a report that will display somewhat as the following:
First Name: Jeff Last Name: Smith
Notes:
This is note 1 for Jeff Smith
This is note 2 for Jeff Smith
This is note 3 for Jeff Smith
This is note 4 for Jeff Smith
First Name: Kim Last Name: Yung
Notes:
This is note 1 for Kim Yung
This is note 2 for Kim Yung
Thank you for any thing on this to lead me in the right direction.

Okay - so I made a query to use as the Record Source for the Report.
SELECT People.ID,
People.FirstName,
People.LastName,
Notes.NOTES
FROM People INNER JOIN Notes
ON People.ID = Notes.ID;
I clicked report design, set this query as the Record Source for the report.
I added a GROUPING on ID (this is to separate each person's Notes).
This created an ID HEADER, which is where you put FirstName, LastName, and your Notes label.
In the Detail section, you put the NOTES field from your query.
Output
If you have any other questions, let me know.

What you need is a Subreport. A Report that will have another report in it. This works in a similar way to a Main Form and Sub Form. More information is available on the MS Office website : https://support.office.com/en-ca/article/Create-and-use-subreports-816f987a-4615-4058-8f20-ce817093bb33

Related

How to call different data from one column via intermediary table?

At first I have to say that I am an absolute SQL newbie.
I have two SQL tables. The second one is an intermediary m:n table.
Table: people
id
name
1
Yoda
2
Anakin
3
Luke
4
Obi-Wan
Table: master-padawan_relation
master_id
padawan_id
1
3
4
2
master-padawan_relation.master_id and master-padawan_relation.padawan_id both refer to people.id.
Now I want a query that shows the following data:
Master
Padawan
Yoda
Luke
My query looks currently like this but it lacks the integration of the Masters name:
SELECT
people.name AS Padawan
FROM
people
LEFT JOIN
master-padawan_relation ON master-padawan_relation.padawan_id = people.id
WHERE
people.id = 3
I don't know how to get that Masters name in there, because both names are in the same column (people.name).
I also managed to get the masters id, but I really need that name.
Appreciate every help! Thank you :)

How to improve/maximize current Database/Table Structure efficiency?

The current structure of my Database tables are as follows; I have two tables, Users, and Skills, with the following columns:
Users
user_id f_name l_name biography password email role
_____________________________________________________________________
1 John Program Short Bio Password johnprogram# Programmer
2 Jeff Analyst Another Bio Password jeffanalyst# Finance Analyst
3 Mister Manager My Bio Password mrmanager# Project Manager
Skills
user_id skill_1 skill_1_details skill_2 skill_2_details skill_3 skill_3_details
_________________________________________________________________________________
1 PHP John writes PHP Python John writes Python Perl John writes Perl
2 Excel I use Excel daily SAP SAP Reporting Reporting Reports created with Excel
3 Billing Oversee Bill. Team Workflow Assignment I assign team acc.
Whenever I am querying the data in the tables to display on a Profile Page, the info is displayed as follows:
Name: John Program
Role: Programmer
Short Bio
Skill: PHP
Details: John writes PHP
Skill: Python
Details: John writes Python
Skill: Perl
Details: John writes Perl
Questions:
1) What re-adjustments/changes should be made to the table structures to increase efficiency/flexibility given the display requirements?
2) If I were to add a "Previous Projects Using Skill" column, for efficiency, would I add it to the second table as follows?:
user_id skill_1 skill_1_details projects_using_skill_1
_________________________________________________________________________________
1 PHP John writes PHP 8 Python John writes Python Perl John writes Perl
2 Excel I use Excel daily 12 SAP SAP Reporting Reporting Reports created with Excel
3 Billing Oversee Bill. Team 3 Workflow Assignment I assign team acc.
For the skill - user relation, you can have two different solutions: if each user has its own skills and details, than you can use a skill table to represent them, with only one skill per user per row (so if a user has four skills, the table will have four rows):
Skills (user_id, skill, detail)
with primary key the couple user_id, skill.
In this way, to find all the skills for a certain user, you can join the two table and find all the relevant information.
If instead several users can have the same skills, you should use three tables:
Users (user_id, f_name, ...)
Skills (skill_id, skill_name, skill_detail)
UsersSkills (user_id, skill_id)
or, if you want that each user has its own details about a skill, but you want to share the skills, you could do something like the following:
Users (user_id, f_name, ...)
Skills (skill_id, skill_name)
UsersSkills (user_id, skill_id, skill_detail)
For your second question, if a user has done several projects using a certain skill, assuming that you have selected the first solution above, you can define a new table:
ProjectUsers (user_id, skill, project_id)
with primary key all the three attributes, and with user_id, skill foreign key for the Skills table.

SSRS - Creating distinct parameter values from SSAS OLAP cube

I have a list of names and email addresses (formatting below) and need to pull back only the names portion, and I need them to be in a distinct list to populate in a parameter.
Current List
Jane Doe (jdoe#example.com)
Jane Doe (jsmith#another.com)
Jane Doe (frosen#whoknows.com)
John Smith (kmittens#santa.com)
John Smith (wlamberson#rogerthat.com)
Desired List
Jane Doe
John Smith
Since the data source is an SSAS OLAP cube I cannot write a "select distinct" query within my dataset. Instead I am limited to using the Query Designer via a shared data source connected to the cube.
Has anyone else ever run into anything like this and found a solution? I've been looking all over and can't find anything.
Any help would be appreciated!
Thanks
Try this:
With MEMBER [Measures].[Name]
AS
LEFT([Customer].[Customer Name].CurrentMember.Name,
InStr([Customer].[Customer Name].CurrentMember.Name,'(')-2
)
select [Measures].[Name] on columns,
DISTINCT([Customer].[Customer Name].[Customer Name]) on rows
from [Mycube]
It will give you a list of distinct customer names as long as customer name is composed of:
name (email)

Keep group rows then begin next group

Imagine 3 tables:
Tickets
Comments
Attachments
The relationship is one ticket has 0 to many comments
Also one ticket can have multiple (0 to many) attachments
Example:
Ticket 1
1 Comment
2 Comment
3 Comment
1 Attachment
Ticket 2
1 Comment
Ticket 3
1 Attachment
I am using reporting services and I created a table layout report that has 3 groups.
The group for the ticket, a group for the comments and a group for the attachments
The issue is as soon as there is an attachment it is displayed after every comment. For instance looking at Ticket 1 from the sample above the report would end up looking like this:
Ticket 1
Comment 1
Attachment 1
Comment 2
Attachment 1
Comment 3
Attachment 1
But I wanted it to display:
Ticket 1
Comment 1
Comment 2
Comment 3
Attachment 1
That is keep the entire group rows together then begin the next group. RS simply displays all the groups and goes back to the original group. I tried several things like creatign a group and merging all the cells and placing a table within it and placed the comments field in this table. Then I added another group and inserted a table for the attachments, etc. When I ran the report its the same issue. How do I display all the data for a group then allow it to go to the next group?
I think the nature of the data means that you can't do this easily in one object, since comments and attachments don't seem directly related there's no natural hierarchy there.
I would create a table with a ticket group and three group header rows, one with the ticket details and two with a subreport embedded in each row; one for comments and one for attachments. Each subreport will take the ticket as the parameter (and any other parent report parameters) and display the comments and attachments associated with that ticket respectively.
It's not the most elegant solution, but it should be easy enough to get going and would definitely get around the problem.

Count a specific value from multiple columns and group by values in another column... in mysql

Hey. I have 160 columns that are filled with data when a user fills a report form out and submit it. A few of these sets of columns contain similar data, but there needs to be multiple instance of this data per record set as it may be different per instance in the report.
For example, an employee opens a case by a certain type at one point in the day, then at another point in the day they open another case of a different type. I want to create totals per user based on the values in these columns. There is one column set that I want to target right now, case type. I would like to be able to see all instances of the value "TSTO" in columns CT1, CT2, CT3... through CT20. Then have that sorted by the employee ID number, which is just one column in the table.
Any ideas? I am struggling with this one.
So far I have SELECT CT1, CT2, CT3, CT4, CT5, CT6, CT7, CT8, CT9, CT10, CT11, CT12, CT13, CT14, CT15, CT16, CT17, CT18, CT19, CT20 FROM REPORTS GROUP BY OFFICER
This will display the values of all the case type entries in a record set but I need to count them, I tried to use,
SELECT CT1, CT2, CT3, CT4, CT5, CT6, CT7, CT8, CT9, CT10, CT11, CT12, CT13, CT14, CT15, CT16, CT17, CT18, CT19, CT20 FROM REPORTS COUNT(TSTO) GROUP BY OFFICER
but it just spits an error. I am fairly new to mysql databasing and php, I feel I have a good grasp but query'ing the database and the syntax involved is a tad bit confused and/or overwhelming right now. Just gotta learn the language. I will keep looking and I have found some similar things on here but I don't understand what I am looking at (completely) and I would like to shy away from using code that "works" but I don't understand fully.
Thank you very much :)
Edit -
So this database is an activity report server for the days work for the employees. The person will often open cases during the day. These cases vary in type, and their different types are designated by a four letter convention. So your different case types could be TSTO, DOME, ASBA, etc etc. So the user will fill out their form throughout the day then submit it down to the database. That's all fine :) Now I am trying to build a page which will query the database by user request for statistics of a user's activities. So right now I am trying to generate statistics. Specifically, I want to be able to generate the statistic of, and in human terms, "HOW MANY OCCURENCES OF "USER INPUTTED CASE TYPE" ARE THERE FOR EMPLOYEEIDXXX"
So when a user submits a form they will type in this four letter case type up to 20 times in one form, there is 20 fields for this case type entry, thus there is 20 columns. So these 20 columns for case type will be in one record set, one record set is generated per report. Another column that is generated is the employeeid column, which basically identifies who generated the record set through their form.
So I would like to be able to query all 20 columns of case type, across all record sets, for a defined type of case (TSTO, DOME, ASBA, etc etc) and then group that to corresponding user(s).
So the output would look something like,
316 TSTO's for employeeid108
I hope this helps to clear it up a bit. Again I am fairly fresh to all of this so I am not the best with the vernacular and best practices etc etc...
Thanks so much :)
Edit 2 -
So to further elaborate on what I have going on, I have an HTML form that has 164 fields. Each of these fields ultimately puts a value into a column in a single record set in my DB, each submission. I couldn't post images or more than two URLs so I will try to explain it the best I can without screenshots.
So what happens is this information gets in the DB. Then there is the query'ing. I have a search page which uses an HTML form to select the type of information to be searched for. It then displays a synopsis of each report that matches the query. The user than enters the REPORT ID # for the report they want to view in full into another small form (an input field with a submit button) which brings them to a page with the full report displayed when they click submit.
So right now I am trying to do totals and realizing my DB will be needing some work and tweaking to make it easier to create querys for it for different information needed. I've gleaned some good information so far and will continue to try and provide concise information about my setup as best I can.
Thanks.
Edit 3 -
Maybe you can go to my photobucket and check them out, should let me do one link, there is five screenshots, you can kind of see better what I have happening there.
http://s1082.photobucket.com/albums/j376/hughessa
:)
The query you are looking for would be very long and complicated for your current db schema.
Every table like (some_id, column1, column2, column3, column4... ) where columns store the same type of data can be also represented by a table (some_id, column_number, column_value ) where instead of 1 row with values for 20 columns you have 20 rows.
So your table should rather look like:
officer ct_number ct_value
1 CT1 TSTO
1 CT2 DOME
1 CT3 TSTO
1 CT4 ASBA
(...)
2 CT1 DOME
2 CT2 TSTO
For a table like this if you wanted to find how many occurences of different ct_values are there for officer 1 you would use a simple query:
SELECT officer, ct_value, count(ct_value) AS ct_count
FROM reports WHERE officer=1 GROUP BY ct_value
giving results
officer ct_value ct_count
1 TSTO 2
1 DOME 1
1 ASBA 1
If you wanted to find out how many TSTO's are there for different officers you would use:
SELECT officer, ct_value, count( officer ) as ct_count FROM reports
WHERE ct_value='TSTO' GROUP BY officer
giving results
officer ct_value ct_count
1 TSTO 2
2 TSTO 1
Also any type of query for your old schema can be easily converted to new schema.
However if you need store additional information about every particular report I suggest having two tables:
Submissions
submission_id report_id ct_number ct_value
primary key
auto-increment
------------------------------------------------
1 1 CT1 TSTO
2 1 CT2 DOME
3 1 CT3 TSTO
4 1 CT4 ASBA
5 2 CT1 DOME
6 2 CT2 TSTO
with report_id pointing to a record in another table with as many columns as you need for additional data:
Reports
report_id officer date some_other_data
primary key
auto-increment
--------------------------------------------------------------------
1 1 2011-04-29 11:28:15 Everything went ok
2 2 2011-04-29 14:01:00 There were troubles
Example:
How many TSTO's are there for different officers:
SELECT r.officer, s.ct_value, count( officer ) as ct_count
FROM submissions s JOIN reports r ON s.report_id = r.report_id
WHERE s.ct_value='TSTO'
GROUP BY r.officer