free form report with SSRS - sql-server

I need to create a free form report which contains questions (question groups contain groups of similar questions....for example personal information, medications, emergency contact information etc) and answers for each of the questions for person.
My query goes something like this:
SELECT person.person_Id,
,question_group.name AS Question_Group
,question_instance.name AS QAsked
,question_instance.answer AS QAnswered
FROM person
INNER JOIN question_group....
So when I create a list using SSRS, using this tutorial (https://msdn.microsoft.com/en-us/library/ff519552.aspx) the only thing that appears on my form is the first question and its matching answer for the person...however, I want to be able to show all the questions/answers for each person on a page (so I'm grouping by person_id), and then show the next person and his questions/answers on the next page.
How can I iterate through these questions for each person, and am I able to move each question around in order to design a form, so the first name, last name questions can appear at the top of the page,...the questions which deal with emergency contact would appear middle of the form, etc...
I'm using SQL 2012, Microsoft Visual Studio Shell 2010 as well as Microsoft SQL Server 2012 Report Builder 3.0
I would greatly appreciate your advice on how to accomplish this.
Thanks in advance for your feedback.

Related

Populating a Column in a Relation Using SQL Update Table and Set Commands in MS Access

I am using MS Access 2016 to learn SQL as part of a class on the fundamentals of databases. I am tasked with adding a new column to a table and then populating that column. The column should reveal whether an account is paid in full or if a balance remains to be paid. Based on that criteria it contains only 'Yes' or 'No.' The formula relies on data from two tables (ENROLLMENT and COURSE).
Here are the tables I created:
I have been researching the problem here and on other sites but not finding the logic and only getting syntax errors.
Here are a couple ways I have tried
I am looking for the direction to go to approach the issue and not asking for someone to do the coding for me. Can anyone point me in the right direction?
The following should help populate the column you want to create:
SELECT ENROLMENT.AmountPaid, IIf([ENROLMENT]![AmountPaid]>0,"Yes","No") AS Paid
FROM ENROLMENT;

crystal reports missing columns

OK, first question here so go easy!
Let's start with some quick background - I have been working with Crystal almost daily for the past 15 years to so, so I like to think I am not too much of a dummy.
Today, I have stumbled across a problem I have never seen.
My source data is from SQL Server 2012 Standard.
I have created a view, nothing too complicated. It grabs PartNo and Description from an Inventory Main table. Then a few other columns from other related tables so I can see the data neatly in a single view, so stuff like carton qty (how many units go into 1 carton), height, length, depth.
Now, bear in mind I have done these kinds of views so many times in the past I couldn't even count.
Now, in Crystal Reports 2013, I connect to SQL via OLE using sa credentials, find my view. Pop over to the "Links" tab in the Database Expert, and my columns created from the related tables are not listed! Only PartNo and Description are visible.
I have scratching my head over this for the past few hours & the only thing I can put it down to is some kind of weird Microsoft update.
My SQL view results:
SQL view
What I see in Crystal
Database Expert, Links
the other way to test this is instead of a view or table just add a
command and select * from yourview
the only downside i think would be using sql expression from a command connection.
another option is to
To define the data type in the view... same with dates. does not like
to be converted otherwise will treat it as a string

MS Access loading values from a different table to control source in datasheet form

please bear with me; I'm not particularly confident with MS Access, although I am quite experienced with SQL Databases from website work.
For my sins, I have been tasked with developing a database which will unify the hundreds of spreadsheets which we currently use to record details of our clients, work, and other stuff... The database is established and built, but I am now working with the forms to allow data entry.
I have a datasheet form (we have a member of admin staff who is hell-bent on refusing to use forms, so a datasheet form seems to be the best way to appease her!) and it is bound to a specific table ('referrals') to allow a user to input data into that table. It looks like this:
However, I need to be able to load values from another table ('pupil_details') into the 'UPN' field so that if a pupil already exists in the 'pupil_details' table, the user can pick that pupil and have their details automatically filled into the form for convenience.
The form's Record Source is currently:
SELECT referrals.*
FROM referrals;
The most obvious way to do this seemed at first to be to use a join query for the form's record source, along the lines of:
SELECT referrals.*, pupil_details.UPN
FROM referrals LEFT JOIN pupil_details ON referrals.UPN = pupil_details.pupil_id
and then use this as the control source but when I do this, it breaks the functionality of the form (displays all the records, prevents it being used to enter data)
So, can anybody suggest to me how I might be able to get the 'UPN' field to display a list of records based on this query when a user types into it:
SELECT pupil_details.UPN, pupil_details.name, pupil_details.date_of_birth FROM pupil_details
But then enter the details into the 'referrals' table when the user submits the form? Sort of like this that I mocked up in Photoshop:
I'm stumped, and half a day on Google has left me none the wiser... :(
Thanks!
You should use a continuous form, not a datasheet, it will give you a lot more control, but still look like Excel. Once you have the form, you can add a combobox to get the details you want. It is nearly always best to avoid Excel attitudes in Access.

Use a query to sort a report in MS Access

I am a beginner in MS Access and am currently stuck with a problem.
I have a database about movies and I'm currently creating a list of all the movies that I want to have sorted by popularity.
To determine the popularity of a movie I have a different table that has a history of what my customers have watched, every movie they have watched is a seperate entry in that table.
I have created a report that has 3 things, the title of the movie, the ID of the movie and a button to watch that movie. But I want to sort the report to show the movies with the most viewers first.
I have created this code in SQL Management Studio which works exactly like I want too:
SELECT [Film].[Titel], [Film].[Film_ID], COUNT([historie].[Film_ID]) as timesWatched
FROM [Film] INNER JOIN [historie] on [Film].[Film_ID] = [historie].[Film_ID]
GROUP BY [Film].[Titel], [Film].[Film_ID]
ORDER BY timesWatched DESC
I'm not that good with Access yet and have no idea how I can use this query to sort the report, I tried putting it in the row source (with everything on one line) in the report properties, which didn't work.
I hope someone has an idea on what to do, is it possible to use this query somewhere or should I use something else than a Report?
Thanks in advance for the answers!
If I'm not wrong..
First create the Query in ACCESS (Create tab -> query) There you will be able to create that query, save it, then go to your report and set its source to this query, the last step will be to set each textbox/label source to the query field, I mean if you have a textField in your report where you want to diplay "movieName", you must select data source from this text box and choose between all fields in your query (in this case, and following a good practice, let's say the field is called movieName too).

Populating MS Access form from ComboBox selection(variable number of rows to populate)

Here's the general schema for my tables(incomplete)
Employees(**EMPiD**, FirstName, Lastname, cell, name)
Trainers(**TrainerName**, Specialty)
EmployeeTrainingCompleted(**EMPID,TypeTraining,** TrainerName, Score, Comments)
Training(**TypeTraining,PositionTitle**) //this one is fishy, and likely subject to change, but irrelevent to this question
Position(**PositionTitle**,Description,StartingPay)
I am working on an Access 2010 form that will allow the user to select from a combobox the "name" field of a particular employee(which is a calculated field from fname,lname) and view all of the completed training, trainer name, comments, score, etc for that EMPID.
I have completed forms that do this for a single instance of training, but I would like for there to be one form that will dynamically display an indeterminate amount of rows for each employee(because employees have completed a different amount of training courses).
I am new to Microsoft Access and I was wondering if there is an easy way to accomplish this.
Thanks for your input.
While MySQL and Oracle are useful for the database side of things, they will be of no use for the RAD side. Access is really a RAD tool that generally, but by no means always, uses a Jet/ACE database for a back-end ( https://stackoverflow.com/tags/ms-access/info ).
To get a general idea of what you can do with Access, look at the Northwind Sample database, which you will find in New --> Sample Templates --> Northwind in your Access 2010 or if you intend to work with a web deployment, http://blogs.office.com/b/microsoft-access/archive/2010/07/19/northwind-2010-web-database-is-now-available.aspx.
Calling these "databases" is misleading, in that they include a great deal more than you will find in a database. In this case, have a look at the Order Details form under Customers & Orders.
I am not sure about the 2010 version of Northwind, but the earlier versions used to come with a warning that you should disregard any code and just use them for ideas on what you can do with MS Access. For code, consider these books MS Access 2003 - Good book on learning advanced VBA.

Resources