Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Reports don't know anything about data. All that report knows is formatting, this font and this color and this position and that's it. For all of their data needs, reports rely on a data source. Data comes either directly from a Table or a little more roundabout from a Query. The nice thing about using a Query as a data source is that you can bring in fields from multiple related tables, calculated fields and added expressions and give it all to the report in one nice and tidy package. When using a Query, you have the option of using a pre-build query that you could find in the Navigation Pane over here or create what's called an Embedded Query directly inside of the reports.
Let's take a look at how our reports get data by having the way they walk us through the first two steps. We can find the Report Wizard on the Create tab right here in the Report section. I will click Report Wizard. Let's work towards getting a report that looks at our customers orders. Now the Report Wizard looks and feels just like the Query Wizard if you have ever use that feature and that's because essentially, that's exactly what we were doing here. We are just building a query with a few added steps to design the report. We are going to start our report with information from the Orders table. I will select it from the list, and then I will add Order ID, Order Date, Customer ID and Product ID to the table.
We will go back up here and select a related table, the Direct Customers table at the top, and from here I will get FirstName, LastName and State. Finally, I need to get the price of the products so I can get their total spent, I can get that from the Products table and that's where I will find Price. We will add that to my report as well. Go ahead and say Next, Access asks as how do we want to view our data? This window looks identical to when we saw in the Form Wizard. We could choose by tbl_Products to group everything by Price or by Customer to group everything by name.
I'm going to leave it as by Table Orders, go ahead and say Next. Now within that, how do I want to group our data? I want to group it by State and then add over, go ahead and say Next. In the sorting section I want to sort by Price and I want to sort it Descending, so the highest value appears to the top. Go ahead and say Next. It looks at the default Layout and Orientation for the paper and say Next. And we will go ahead and give this a title. We will call it OrdersByState. We will choose to Preview the report and say Finish.
So here is our basic report. We can see we have everything grouped by the state. I have got the summarize total of the spend in Price here, descending I have got the OrderDate, the CustID, the Products that they ordered and the First and Last Name of the person who ordered it. Let's go ahead and take a look at this in Design View. I will Close Print Preview and I return them into Design View. Now let's take a look at where that query went that we just built with the wizard. If I go to the Property Sheet here and if it is not selected, we will select entire report by clicking this black button between the rulers. We will look at the Data tab and the Record Source we can see the Select statement.
Now if you have taken my Queries in Depth course here at lynda.com, this might look really familiar to you. This is telling me that this is using a query in the background. I can click the Build button to see that query. That will take me into a Query design session where I could take a look at what the Wizard created for us as we click through the menus. We can run this query just like any other query to see the data table behind it. I will click on Run. And I can see that data table. So this is a data that's getting formatted by the report. Let's go ahead and back in the Design View for the query. The name of the query right now is Orders By State : Query Builder.
This is telling me that this is a query inside of this report. It's not going to exist in my Navigation Pane over here. Now we can edit this query, for instance, you might want to make changes to a query and you might think, well if I want to summarize by Total price, I can click on the Totals button here and I scroll over to price, and under Total I could say, Sum, if I Run the query, the query works just fine. The problem is, is that Access has created links to the field names in the query, to the text boxes that are in the report already. And when I group by SumOfPrice, it changed to the column name from Price to SumOfPrice, and thereby breaking the link to the fields that are already on the report.
Now you can fix this, there is no problem with that. But it does take a lot of clicking. But now that we know what powers the Record Source for our reports, let me go ahead and back out to this query and I am not going to save any changes. We have got the Select statement here is where the date is coming from our Record Source. I have got the Select statement here, it's providing the data for the report. I could also use the drop-down menu here, to select any of the Queries or Tables so I could manually choose a Record Source. We can smooth out our workflow by first creating a query that gathers exactly the information we want including any aggregation or calculations, and then build a report on that afterwards.
That's going to be topic of the next movie. Now one last thing, the Record Source property in the Reports functions exactly the same way when bringing data into a form. You can go back through some of the forms that we have created throughout this course, explore the record source property and find out if we're using a table reference, a query reference or an embedded query to generate those records. Of course with forms, you also have the option of having an unbound form, that isn't connected to any data source, such as our Splash Screen and our Main Menu forms. Whereas reports, we will kind of worthless if left unbound.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 99159 Viewers
80 Video lessons · 141793 Viewers
59 Video lessons · 60161 Viewers
52 Video lessons · 73297 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.