navigate site menu

Start learning with our library of video tutorials taught by experts. Get started

Access 2013 Essential Training

Access 2013 Essential Training

with Adam Wilbert

 


Join author and database expert Adam Wilbert on a tour of the essential features of Microsoft Access 2013 and discover how to build a database and store your data more efficiently. First, Adam explains the concepts behind relational databases, before moving onto building tables—the foundation of any database. He then shows how to define the relationships between tables and use queries to find and filter data. The course also shows how to apply rules and validation to minimize data entry errors; build an interface for the database from forms, complete with interactive buttons and combo boxes; create reports for printing and sharing; and automate these tasks and many others with macros.
Topics include:
  • Understanding table structures and relationships
  • Setting primary and foreign keys
  • Establishing relationships and maintaining referential integrity
  • Sorting and filtering data
  • Building queries with constraints and criteria
  • Editing table data with queries
  • Generating forms from tables
  • Adding form controls
  • Creating reports with totals and labels
  • Embedding macros in buttons
  • Repairing your database
  • Protecting databases with passwords

show more

author
Adam Wilbert
subject
Business, Computer Skills (Windows), Databases
software
Access 2013, Office 2013, Office 365
level
Beginner
duration
5h 4m
released
Feb 08, 2013

Share this course

Ready to join? get started


Keep up with news, tips, and latest courses.

submit Course details submit clicked more info

Please wait...

Search the closed captioning text for this course by entering the keyword you’d like to search, or browse the closed captioning text by selecting the chapter name below and choosing the video title you’d like to review.



Introduction
Welcome
00:00(music playing)
00:04Hi! My name is Adam Wilbert and I would like to welcome you to Access 2013
00:08Essential Training.
00:09We'll start by taking a look at what makes the relational database work, and how
00:13moving your information into Access can help make you more efficient with your
00:17time and with your data.
00:18We'll build tables to store our data and attach rules to help minimize data
00:23entry errors in order to ensure that our data remains consistent and reliable.
00:27Next, I'll introduce Queries, a powerful way to find, filter and sort your data
00:32in order to reveal exactly the information you need precisely when you need it.
00:37With forms we'll create a main user interface to your database.
00:41We'll build custom interactive elements with buttons and combo boxes to help
00:44us populate a database with data, and move around to accomplish different tasks efficiently.
00:50Reports will help us create a structure for printed documents and allow us to
00:53easily share insights about the data.
00:55And finally, Macros will help us automate tasks and keep everything running smoothly.
01:00So thank you for joining me in Access 2013 Essential Training.
Collapse this transcript
Using the exercise files
00:00If you are a premium member of lynda.com or watching these movies from a DVD,
00:05you'll have access to the same files that I am using here on screen.
00:08You can copy the folder to your desktop as I have done here or anywhere that is
00:12easy for you to get to.
00:13Inside the main folder are subfolders for each chapter, and within those are the
00:18files that I'll be using.
00:19You'll see the name of the file display across the bottom of your screen at the
00:22beginning of each movie.
00:24In some cases there will be a completed version of the database file as well
00:28that you can refer to if you'd like.
00:30And a word of caution, because Access saves changes to files automatically
00:34while you're working with them, I would highly recommend returning to a clean
00:37and unaltered copy of the files if you would like to work through and exercise
00:41multiple times.
Collapse this transcript
1. Getting Started
Key database concepts
00:00Before we begin in Access, I think it's important to outline a few key concepts
00:05about what a database is and define some of the keywords we will be hearing
00:09throughout the course.
00:10So what is an Access database?
00:12An Access database is not just a place to store your data;
00:16it's a tool for creating custom application that wraps the entire interaction
00:19between you, your team, and the data.
00:22Access is a collection of tools that allow you to efficiently process data,
00:26moving it in and out of the database, maintain the quality of the data, and
00:30ensure that it remains consistently entered and valid.
00:33Gain insight into the trends, areas of opportunities and performance metrics
00:38through a series of analytical processes, construct organized and detailed
00:43reports to help guide informed decisions, and automate tasks to help prevent
00:47processing errors and speed up workflows.
00:50Simply put a well-crafted Access database can give you way more than you put into it.
00:55To do all of that, an Access database uses five main components.
00:59These components are collectively called database objects, and each has a unique
01:03role to play in managing your data.
01:06The first object is a table.
01:08Tables are where the data lives.
01:10They provide a structured home organized into fields and records.
01:14The next objects are queries.
01:15Queries are literally questions that you have about the data.
01:18Queries scour through your data tables to find the answer to a question and
01:22then return an answer as filtered or calculate a list of records that look and
01:26function just like a table.
01:28Forms provide interactive framework for your database.
01:31They hold buttons for moving from task to task, text entry fields, to help you
01:35enter data into your tables and input areas to help you define the parameters
01:39for query or report.
01:41Reports gather information from a table or query and then format them for
01:45a standardized page layout ready to be printed, exported, or emailed to colleagues.
01:51Finally, macro objects are sets of programmatic instructions that you will create
01:55to tell the database how to function when you click on a button or interact with
01:59a form or other object.
02:01They can automate some fairly complex tasks.
02:03It is the interaction of these five components that makes the database function.
02:07For instance, a form might help you enter data into a table, a query will then
02:12filter those records to a specific subset, and then a report will format that
02:16subset of records for printing.
02:18To create our objects we will be using multiple working modes called Views.
02:23These can be grouped into two categories.
02:25The standard view is the one you will use when you are working with your data.
02:29Depending on the object, we will use Datasheet, Form, Report or Print Preview Views.
02:35These will display our objects when we are working with the information
02:38contained within the database.
02:39The other views are used when creating or modifying the structure of the objects.
02:43The Design, Layout, and SQL Views all allow you to define how the
02:48database functions.
02:50Finally, it's important to understand the relational structure of an Access database.
02:55Take a look at the following problematic table of contact phone numbers.
02:59In this table, you will notice that the first and last names are repeated
03:02over-and-over again every time if there is an additional contact phone number.
03:06We can structure this data differently but that introduces a new problem.
03:11Now we have lots of blank cells where individuals don't have a contact number of each type.
03:15Further this table won't grow very well.
03:18What if we wanted to add a fax number for one individual or a second office number?
03:22We would have to alter the structure of the table to add an additional column to
03:26accommodate those types of changes.
03:28A relational database solves both problems.
03:32Unlike a flat file database such as an Excel spreadsheet, Access organizes
03:36data into multiple tables that connect to each other through common fields called keys.
03:41Using the exact same data, we can organize our phone numbers like this where
03:45we have one table that's just about people, and another table that's just
03:49about phone numbers.
03:50By linking the two tables together with a key, in this case an employee ID, we
03:55can accommodate growth and prevent inefficiencies in our storage.
03:59We can easily add new people or additional types of contact numbers without
04:03altering the structure of the tables.
04:05We will expand in all of these concepts throughout this course and we will be
04:09creating several objects in each of the five types, hooking them together to
04:12build a relational database that will efficiently store data, return answers to
04:16our questions, perform analysis, and generate reports.
Collapse this transcript
Launching Access and the Backstage screen
00:00Starting Access for the first time is pretty straightforward, we'll my move my
00:04cursor up to the top-right corner and then down to reveal the Search charm.
00:08I'll click it and then type-in the word access.
00:12The results get filtered and it brings up the Access 2013 tile here.
00:16I am going to press my Windows key to return back to the Start menu.
00:20Instead of going to the Search charm, I can actually just start typing.
00:23If I type-in access it automatically jumps to Search and there is the tile again.
00:28Now instead of clicking on it, which will launch the program, I'm going to
00:31right-click on it, which will bring up additional options.
00:33I can choose to Pin the tile to my Start window.
00:37If I right-click again, I can choose to Pin an icon to my Taskbar, which will
00:41make it easy to get to Access from my Desktop.
00:44I'll turn both of those options on.
00:46Now I am going to press the Windows key one more time and you'll see if I
00:51scroll over here to the right, we've got an Access tile here where we can start
00:54the program quickly.
00:55I am going to click and drag to move the Access tile over to the beginning of my Start screen.
01:00Now I have an easy way to launch Access.
01:02Let's go ahead and click it.
01:04When we switch into the Desktop view an Access starts up.
01:07If I look at my Taskbar down at the bottom of the screen, we'll see an icon for
01:12Access where we can get to it quickly when the program is closed.
01:16Now that our window is open we can move it around the screen.
01:19If I click and drag over here to the right side, I can launch Access and attach
01:23to the right side of my screen.
01:25If I drag it over to the left, it will fill up the left-half of my screen, and
01:30if I want to go full screen I simply drag it to the top and Access will go full screen.
01:35Now that we've got Access up and running and our window arranged how we like,
01:38we can start to create our first database.
Collapse this transcript
Creating the database file
00:01Unlike other Office programs that immediately give you a blank document to get
00:05started in, Access starts with the options for creating a new database, or
00:08opening an existing database.
00:10On the first screen we'll see a list of available starting templates here.
00:14We have templates for Assets, Business, Contacts, and so on;
00:18above that we have a box, so we can Search for templates.
00:20I'll click here and type vehicle.
00:23When I press Enter, Access searches through the available templates online and
00:27returns this Desktop Vehicle maintenance database template.
00:31If I am interested in it, I can click on it to get some additional information
00:35such as how big the file is, what kind of rating it's gotten from other users.
00:39And if I decide to use this, I simply give it a name and press Create.
00:43Access will download this template to my computer and I can begin using it.
00:46I am going to press the Close button on the upper right-hand corner to
00:50dismiss this window.
00:51Then I am going to press the Back button here at the top left to return to the beginning.
00:57Now any of the templates that use the web app phrase like the Custom web app
01:00here or the Globe icon such as this Context template, these templates use
01:06the web-based SharePoint servers to host your database and make it available over the Internet.
01:11In order to create a web app database you'll need access to a self-hosted
01:15SharePoint server or have an active subscription to either Microsoft Office 365
01:20Small Business Premium, or Office 365 Enterprise.
01:24For more information about Office 355 Plans & Pricing visit
01:28office365.microsoft.com.
01:31In this course we are going to focus on the desktop database.
01:34These types of databases allow you to create self-contained databases that run
01:38right from your local computer or network without the added complexity of
01:41managing servers or subscriptions.
01:44These tablets are great if you just want to get up and running with the task
01:48of storing your data, but they are also a great resource for learning about how Access works.
01:52Some of them include very sophisticated layout ideas and techniques that can
01:56help give you ideas of the things that you can add to your own databases.
01:59So even if you don't need an asset-tracking database, for example, it might be
02:03worthwhile to spend a few minutes exploring the template, taking it apart to see how it works.
02:09If you don't want to start with a template the left-hand side of the screen has
02:13a listing of Recent files, if you have opened any previously, and we also have an
02:17option to Open Other Files, go ahead and click there.
02:21This will bring up a new window, we can choose to create a new database, open an
02:25existing database from our computer, checkout our account settings or explore
02:31some Access options.
02:32Let's start a new database by clicking on the blank database icon, and I go back
02:36to New and choose this Blank desktop database.
02:41Access asks us for a name for our database.
02:43I am going to call this NoObstacles.
02:45We are going to create a database for the NoObstacles Home and
02:48Furnishing Company.
02:49Go ahead and click on the folder icon to choose where we are going to save this database.
02:53I am going to browse out to my Desktop.
02:55I am going to find my exercise files folder and I am going to go into the
03:01Chapter 01 folder and say Open, and then OK to save my database.
03:06Access updates the path here and now I press the Create button to create the new database file.
03:12Access creates this file and opens up a new Data Table ready for us to
03:16start entering our data.
03:18Now that we have got our database file created, we can begin to explore
03:21the Access interface.
Collapse this transcript
Understanding the Trust Center
00:00All Access database files have the potential to contain dangerous or malicious
00:04code buried within embedded macros and Visual Basic routines.
00:08If you are unsure of a database's origins, you should be very careful about
00:12allowing them to run before you've had a chance to check them out and make
00:16sure that they are safe.
00:17Because of this, Access requires you to give specific permissions to a database
00:21file before we'll activate and run any code within the database.
00:25When opening a new file for the first time Access will display this yellow
00:29security warning across the top.
00:31There are couple of things that we can do to handle this warning.
00:34First, I can click on the X on the top-right to dismiss the warning.
00:38Access will continue to let us work, but it won't run any macros or code modules.
00:43This could prevent the database from functioning properly.
00:45If I click the Enable Content button to trust this particular file, Access will
00:51remember this file and it won't ask us again the next time we work with it;
00:55or I can click on the text here, when I hover over it becomes underlined, I'll
00:59click on it to get some additional options.
01:01We've got a Security Warning box here, where we have links to the Trust Center
01:06Settings and links to Learn more about Active Content.
01:10The Enable Content button here, if I click it, we can enable the content for our
01:14database or we can get to some Advanced Options.
01:17I am going to click on Enable All Content.
01:20Now our database is trusted and code will run.
01:23Trusted documents are files that you've previously granted Access permission to run.
01:27We can also trust a location on our computer and then any files in that location
01:31will automatically be trusted as well.
01:33Let's go ahead and trust the lynda.com exercise files location so that we aren't
01:38bothered with the security message throughout the remainder of the course.
01:41I am going to go up to the File tab and then down to Options that will bring up
01:47the Access Options window.
01:48The very last option on the left is Trust Center, and then on the right side of
01:52that, Trust Center Settings.
01:54At the top of the next screen we have an option for Trusted Locations, go
01:59ahead and click that, and you'll see a list of all the locations that have
02:02previously been trusted.
02:03Let's go ahead and add our location here.
02:06I'll press the Add the new location button and then browse out to my exercise
02:10files folder location.
02:12I'll click Browse, go out to my Desktop and then go into my Exercise Files
02:18folder, I'll press the OK button to select it.
02:22Make sure you check the subfolders of this location are also trusted.
02:26Now any files in that folder or within subfolders within that folder, are
02:30automatically trusted as safe.
02:33Go ahead and press the OK button, I'll press OK again, and I'll press OK one
02:38more time to close the Access options.
02:41Now if I close this file and reopen it, we won't be prompted to trust it again.
02:45Opening databases that you created yourself, or ones that come from reputable
02:49sources, usually won't pose much of a threat.
02:52But if you are ever unsure about who created a particular database file it's
02:56best to play it safe, and explore its contents before allowing it to run any
03:00code on your computer.
Collapse this transcript
Digging in to Ribbon tabs
00:01All of the tools that we will be using in Access are organized into the same
00:05Ribbon tab layout that is used throughout the Microsoft Office Suite.
00:08These are contextual tabs that run along the top here that change depending on
00:12the context of what you're working on.
00:14By default there are four main ribbons, plus the File tab which takes you to
00:18the backstage options.
00:19Let's take a look at each tab and get a peek at their organizations
00:22starting with that file tab.
00:24Now when I click on it, you'll notice it's not really a ribbon at all, it takes
00:28you to the screen called backstage view.
00:30This where you can Open a new file, Save existing objects, Close the database,
00:36you can also get information about your current user Account and get to those
00:39Access Options and I click the back button on the top to return to the
00:43standard interface.
00:45The rest of the tabs, Home, Create, External Data and Database Tools all have a
00:51similar and familiar layout.
00:53We have objects called Command buttons that are organized into groups.
00:57On the Home tab for instance, we have groups for View, Clipboard, Sort & Filter,
01:02Records, Find and Text Formatting.
01:05And then within these groups are the commands.
01:07For instance in the Clipboard group, we have Paste, Cut, Copy and our Format Painter.
01:13The Sort & Filter group has options for sorting and filtering records.
01:17The Records group has options for adding and deleting records.
01:21The Find group has where you'll find, Find and Replace options, and the
01:24Formatting group has Bold, Italic, Underline and other text formatting options.
01:30The next tab over is the Create tab.
01:32Let's go head and click that and we'll see we have groups for Tables, Queries,
01:37Forms, Reports and Macros & Code.
01:40These are all the different objects that we'll be creating in our database.
01:43We'll be spending a lot of time here in this tab throughout this course.
01:47The next tab is External Data.
01:49The External Data tab is all about bringing data in with the important link
01:52section and out with export section.
01:55You'll see we have lots of options, for instance, we can Import from an Excel
01:59file, or we can Export to a PDF file, there are lots of options here.
02:04Finally the Database tools and we have some specialized tools for maintaining
02:07the database and its components.
02:09Additional tabs will pop up when working with specific objects, for
02:12instance, when we start working with Tables in the next chapter, we'll see a
02:16setup tabs specific to tables.
02:18Now if you are working on a small screen such as a tablet computer, you might
02:22find that the ribbon takes up a lot of your workspace.
02:24You can collapse the ribbon by pressing the up arrow on the right side here.
02:28That will collapse my ribbon so all I see is the text of the tab.
02:32When I want to get to a command button, I'll simply press the tab and the
02:36command buttons appear.
02:37I'll select what I want and then the ribbon will disappear again.
02:41Once the ribbon is collapsed though, it's not really clear on how to get it back.
02:44You can open the ribbon again and I click on this pin icon over here on the
02:48right to lock it open again.
02:50Another way you can do it is to double-click on an active tab, for instance
02:54External Data is active right now.
02:55If I double-click on it, the ribbon will close, double-click again, and
02:59the ribbon locks open.
03:00And if you like keyboard shortcuts, the Ctrl+F1 key will minimize or reveal
03:04the ribbon contents.
03:06One more ribbon trick before we wrap up.
03:08The scroll wheel on your mouse can be used to scroll through the ribbons.
03:11I can scroll backwards and forwards using that wheel.
03:14Simply move your mouse cursor over the ribbon area and scroll up and down.
03:18I'll be honest though,
03:19I accidentally scroll the wheel up here all the time and then wonder why the
03:22ribbon switched on me.
03:23If that's ever happened to you, now you know why, you probably just bumped the scroll wheel.
03:28Now the ribbons have all the tools that we'll want to use to design and develop
03:32our database applications.
03:33Getting used to their organization will be key in being able to quickly get
03:37to the items you need.
Collapse this transcript
Using the Navigation pane
00:00The Navigation panel on the left-side of your screen here is the Table of
00:04Contents for your database.
00:05It displays all the objects, the Tables, Queries, Forms, Reports & Macros that
00:10make up this database.
00:12It also allows you to filter and search through those objects to get to the ones
00:15you are looking for quickly.
00:16Right now the Navigation pane is in its default configuration.
00:20It says All Access Objects across the top.
00:23And I'm going to actually open this up a little by clicking and dragging open to
00:27make it little wider.
00:28Below, we have a search box, so we can type in to filter the list of objects.
00:32I'm going to click here and type phone to see all of the objects that have the
00:36word phone in their name.
00:37When you want to clear the search, click on this filter icon to the right and
00:41that will clear the search string and return you to viewing all objects.
00:44Below each of the objects are listed under a collapsible type header.
00:48Click on the up arrows to the right to collapse the group.
00:50I can collapse of Tables here, then Queries, Forms and Reports.
00:56If I want to work with my Query objects I can simply open it again, use the one
00:59I want and then close it when I'm done.
01:02I'm going to go head and expand all these again.
01:05At the top of the Navigation pane there is a dropdown menu that allows us to
01:09change the configuration of the pane, here.
01:12This menu is separated into two different groups.
01:15The top one says Navigate To Category, and I personally think this should just
01:20simply read grouping, because that's exactly what it does.
01:23We can choose an option in the top half to change the way the objects
01:26are grouped together.
01:27Right now they're grouped by Object Type, but I can group them by Custom group,
01:31by Tables and Related groups, based off of the Date they are Created or the Date
01:36they were last Modified.
01:38The bottom half of the menu says Filter By Group, here we can choose to display
01:43only a single object type.
01:44I'll click Tables to filter my navigation pane to show just the tables in my database.
01:49You'll notice that the top now reads Tables, instead of All Access Objects.
01:53I'll change it back in the dropdown, down here to All Access Objects, to
01:57view everything again.
01:58There is also a right-click menu at the top of the Navigation pane with some more options.
02:03I'll go up here and right-click, you'll see we have the same categories and
02:07sorting options, we can also sort Ascending or Descending alphabetically.
02:11We also have a View By option where I can choose how I want to view my objects.
02:16Right now they are in List view which is a small icon in the text.
02:20I can change it to Details to view a larger icon and some additional
02:23information about each object.
02:24I'm going to go back up and right-click, go to View By, and change it back to List.
02:30If you want even more options, you can go in the Navigation options button here.
02:34This will give us a really detailed look at what options are available for
02:37organizing our Objects menu, go ahead and say OK, and finally in that same menu,
02:43go back up and right-click, we get turn on and off our search bar.
02:47So if you don't use it, you can turn it off here.
02:50If you want to get the Navigation pane out of your way, you can use this Shutter
02:54Bar button here to the right.
02:56If you click it once, the Navigation pane collapses to the left, if I click it
03:00again, it opens up again.
03:01Now one of the most useful keyboard shortcuts in all of Access is the F11 key.
03:05This will collapse and reveal the Navigation pane.
03:07If I press F11, you'll see it shrinks down and it opens up again.
03:12Using F11 you can quickly open up the pane when you need it, then get it off the
03:15screen so you have more room to work.
03:18So that's the Navigation pane.
03:20It's the central hub to the entire database.
03:22Getting around your objects using the Navigation pane is really easy, and with
03:26so many options to Group, Sort and Filter your objects to meet your exact
03:30needs, means that you can be moving around from object to object in the most
03:34efficient manner possible.
Collapse this transcript
Using the Quick Access Toolbar
00:00The Quick Access toolbar is a set of persistent tools that stay at the very
00:04top of your screen.
00:05By default they have options for Save, Undo and Redo.
00:10There is also an option to change the spacing of your command buttons on your ribbon tabs.
00:13I will click this and see that it's currently set to Mouse view.
00:17I can change it to Touch mode, which will increase the spacing, which is perfect
00:20if you are running Access on a Tablet.
00:22I am going to change this back to Mouse.
00:24I can add additional commands to the Quick Access tool bar by clicking this down arrow here.
00:29For instance, I can choose Print Preview to add that to the bar.
00:32If I want even more options, I will click the down arrow and choose More Commands.
00:37That will bring up a window that lists all of the commands available in Access
00:41on the left and the commands I have selected to include on the Quick Access
00:44toolbar on the right.
00:45I am going to choose from the Popular Commands, I will change that to All
00:49Commands and then I will scroll down until I find Save As.
00:52I will click it and then press Add, to add that to my Quick Access toolbar.
00:57If I want to rearrange these, I can use the buttons over here on the right.
01:01I'll select Print Preview and move that up so it appears right after Save As.
01:06Go ahead and press OK to save those changes and you will see the Quick Access
01:10toolbar changes to include the commands that you want to have front and center.
Collapse this transcript
Signing in to Microsoft Live
00:00If you have a Microsoft Live account, you can log into your account right from
00:04inside Access in order to sync files across multiple computers.
00:08To do that, you go to the Sign in link in the upper right-hand corner of your screen.
00:12I will click there and choose my Microsoft account.
00:16Go ahead and type in your Username and Password and press the Sign in button.
00:21If you haven't signed in from this computer before, there might be an
00:24additional step to verify your identify, but once you have signed in, you will
00:29notice your ID photo in the upper right hand corner and your name here showing
00:33that you are logged in.
00:34Now we can go up to the File tab and press Open and see that I have got
00:39access to all the files that I have currently saved within my online hosted SkyDrive folder.
00:44Logging into your Microsoft Live account allows you to sync files easily
00:48across multiple computers.
Collapse this transcript
Taking backups
00:00When working inside of your Access databases, it's really important to make sure
00:04that you've always got of backup in case something goes wrong.
00:08Access makes a super easy to create a backup file, so it's really no reason to not have one.
00:13In order to create a backup, we'll go up to the File tab, and I go down to Save As.
00:17There is an option here called Back Up Database, I'll select that and choose Save As.
00:24Access brings up my Save As dialog box and notice that it's suggested a File
00:28Name of our original database, plus the word Backup, plus today's date.
00:33I simply needed to press Save and Access creates a backup of my file saved on my
00:38hard drive and that's all there is to it.
00:41I can safely proceed with editing my database and know that I've got a backup in
00:45place if something goes wrong.
Collapse this transcript
Accessing help
00:00Sometimes you'll need additional assistance when you are trying to accomplish a specific task.
00:05The Microsoft Office Help documentation is a great resource to have at your finger tips.
00:10You can get to it by clicking on this question mark icon on the top right of
00:14your screen or pressing the F1 key on your keyboard.
00:16When you launch Help, you get a document that looks like this with links to
00:20Popular Searches, such as for Criteria or Queries. Getting Started;
00:25you can find out some information about What's new is Access.
00:28We have linked keyboard shortcuts, which is a handy reference to have up on your screen.
00:32When you get done with this, you can press the Home key here to get back to the main screen.
00:37We can take a look at Basics and Beyond, which has options for Introduction to
00:41tables and Introduction to queries.
00:44One handy button here on the Help screen is this Pin icon here; when you press
00:48this Pin, Access keeps the Help document on top of your screen, so I can switch
00:53back into Access and continue working with my database without the Help document
00:57hiding in the background.
00:59The Access Help document is a great resource when you need additional help in
01:03creating your objects or for learning about how different functions work.
Collapse this transcript
2. Creating Tables
Understanding table structure and relationships
00:00Tables provide the foundation for any good database and the success of the
00:05database, how well it functions, and how flexible it is to future growth often
00:08comes down to the structure of tables that you house your data.
00:11Understanding how tables function in Access is a key to creating a well
00:15structured database.
00:16Tables in Access follow a very strict model.
00:19Their horizontal rows are called records.
00:22Records are an unbroken chain of properties that describe a single entity.
00:25For instance, in an employee's table, you have a record for each individual in the company.
00:31Fields are the vertical columns.
00:34Each field in a table is a single property that is being tracked for each record.
00:39Each field can hold data of a single data type.
00:43You can choose to store short text which are up to 255 characters, long text
00:49with a maximum character limit of 65,000.
00:51This is useful for comments or memos.
00:54Numerical values that you perform mathematical calculations with, these can
00:58be set to integers only or can include decimal values. Date and time or currency values.
01:04AutoNumber fields creating incrementing serial number field that Access creates
01:10for you when new records are added to the table.
01:12Yes/No is a binary field, it can be Yes/No, True or False, or On or Off.
01:19OLE object is an older format used for attaching files such as images or Word documents.
01:24If you need to attach files, I recommend using the newer and much more efficient
01:29attachment data type.
01:30Really the OLE object data type is just kept around for backwards compatibility,
01:34and probably shouldn't be used at this point.
01:37If you'd rather not import files into the database, you can choose to use a
01:41hyperlink data type and provide a link to external content.
01:44This could be files on your network, email addresses, or locations on the Internet.
01:49Finally, the calculated value creates data by calculating it from one or more of
01:53your other fields, and a Lookup Wizard will help you create a dropdown list to
01:57limit the available entries.
01:58In addition to the fields that describe each record's properties, we will also
02:02create fields that link tables together.
02:05Previously, I've mentioned that Access stores data in related tables.
02:09Because of this, each record of the table needs to be uniquely identifiable.
02:13In order to ensure that this is the case, we will create a field specifically
02:17for this purpose called the primary key.
02:19The primary key is typically a serial number or other unique identifier.
02:24Think about how many unique identifiers you have for the various databases that
02:28you personally appear in.
02:30You probably have a driver's license number, a library card number, a Social
02:34Security number, a checking account number;
02:36the list goes on and on.
02:38The reason all of these systems use serial numbers instead of just your name;
02:41so that they can guarantee a unique individual.
02:44It wouldn't be very nice if one Mary Smith had to pay a fine for another Mary
02:48Smith's overdue library book, just because a library couldn't tell them apart.
02:53The primary key will also be our link to finding related records in additional tables.
02:58In a related table they will be called the foreign key.
03:01The process of breaking your data into related tables is called normalization.
03:05Normalization rules fall into several categories called normal forms.
03:10Your database is set to satisfy the first normal form or 1NF, if all of the
03:15cells contain only a single value.
03:16Rather than have a single employee name field, we should break that into
03:20separate first name and last name fields.
03:23Breaking addresses into separate street, city, state, and zip code fields is
03:27another common example.
03:29The second normal form states that only data that is dependent on the primary
03:33key belongs in that table.
03:35We wouldn't want to store information about the customers each employee has
03:38helped in the employee's table.
03:40Instead we should create a new table that describes the interaction between our
03:43employees and our customers.
03:45The third normal form states that data that can be calculated or derived from
03:49other fields should not be stored in the database.
03:52We wouldn't want to create a field for employee initials for example, because we
03:56can easily calculate them by taking the first letter from the first name field
04:00and the first letter from the last name field.
04:03Tables are where your data lives, and are the foundation for your database.
04:07Creating a strong foundation as a base, then growing your database on top, with
04:11the addition of queries, forms, and reports, will mean your database will be able
04:15to be flexible and efficient.
Collapse this transcript
Creating a table and setting data types
00:00When creating a place for our data to live, we will define the columns or fields
00:04that will house the data.
00:06Remember that in a properly normalized data table the fields will represent the
00:09smallest piece of information possible.
00:12So instead of a single name field, we will instead break it out into a first
00:15name, last name, or even middle name, suffix, and prefix fields if needed.
00:20Let's create a table to hold information about the NoObstacles
00:23companies customers.
00:24Now there are a couple of different ways to create a new table in Access, all of
00:28which can be found in a Create tab.
00:30Here in the Tables group, this SharePoint option will create tables on
00:34a SharePoint server.
00:35The other two options are what we are looking for.
00:38We can create a table in either Datasheet view, this option here, or in Design
00:42View with this button.
00:43Let's start creating our customer table in Datasheet view by clicking on
00:47the Table button here.
00:48Access will create a new table for us and sets up the first column named ID.
00:53If I click on it, I can take a look up here in the Data Type to see if that is
00:59an AutoNumber field.
01:00The AutoNumber field is a serial number that Access creates for us automatically.
01:04Now I want to be specific about what type of data this field is holding, so
01:07instead of just ID, I am going to name it Customer ID.
01:10I will double-click on the Text ID to rename it and type in CustomerID.
01:16Go ahead and press tab to move to the next field.
01:20The next field is going to be our first name field.
01:22It's going to be text, so I will choose from the list, Short Text, and then give
01:27it a name, FirstName.
01:30Go ahead and press Tab or Enter to move to the next field, and this time I am
01:35going to keep my hands on the keyboard.
01:37I can use the up and down arrow keys to move to the list of available options.
01:41I can move from Short Text to Number, Currency, Date & Time, Yes/No, Lookup & Relationships.
01:47I can choose Rich Text fields, Long Text fields, I can choose to Attach files
01:51in this field, or create a Hyperlink, and finally, I have some options for
01:55Calculating Fields.
01:57I can also press the underlined letter to jump straight to a field.
02:01So for instance, if I want to go back to the Short Text, I'll simply press the T key.
02:05Now I will give it a name, this is our LastName field.
02:09Notice that when I am naming my fields, I am not using any spaces here.
02:13Now Access will totally allow you to use a space in the names, it's okay with that.
02:17But as a standard user interface convention, I tend to use camel casing, which
02:21means all the words run together and we capitalize the first letter of each new word.
02:26I'm sure you'll find the convention that works for you.
02:28As long as you're consistent that's really all that matters.
02:30Let's take a look at the ribbons now.
02:33Notice that while we are working with the tables, we've got two new tabs up here at the top.
02:38They are into the Tables tools group;
02:40we have got Fields and Table.
02:41Within the Fields tab we have Groups to Add new fields here, Add & Delete.
02:45We can change the Properties for our fields here, we can change the Formatting
02:48for those Text Fields and we can set up some Validation rules.
02:52I am going to add another field here for my phone number.
02:55Now you might think that you are going to use this number button here in the Add
02:59& Delete group, to add in the Phone Number field.
03:02But a phone number is actually going to be added as Short Text.
03:05Phone numbers aren't something that we are going to be mathematically
03:07calculating or deriving from.
03:09You are not going to add two phone numbers together for instance.
03:12Plus for a phone number field, we want to store the parentheses and hyphens,
03:16the punctuation marks.
03:17Remember, Short Text could be good for alpha and numeric data.
03:21I am going to press that button and it adds a new field over.
03:25Now we can give it a name, I am going to call it CustomerPhone and press Enter.
03:31Now I don't want to add anymore fields here, so I am just going to go ahead and
03:36save the construction of my table.
03:37Up here on the Quick Access toolbar, I have got a Save icon.
03:40This is purple disc, I will go ahead and click that and it brings up the Save As dialog box.
03:45You can also use the standard Windows, Ctrl+S shortcut key to bring up the
03:49Save As dialog box.
03:50We are going to go ahead and give our customers Table the name, Customers and
03:54press OK to save it.
03:56You will notice that it updates over in the Navigation pane on the left, now our
04:01database is beginning to take shape.
04:02We have a table created where we can begin to collect information about our customers.
04:06Access created a primary key for us with this ID field and we added three text
04:11fields to hold the last name, the first name and the customer's phone number.
Collapse this transcript
Entering data
00:00Adding new records to your database is as easy as filling in the blanks.
00:04Each Record or horizontal row will contain information about a single entity.
00:08In our case the Customers Table will collect information about our individual
00:12customers with each row containing information about one customer.
00:16Let's start to put a couple of records into our database.
00:19I am going to open up the Customers Table we created in the last movie.
00:22I'll double-click on it in the Navigation pane to open it.
00:25I am going to add three new customers here, the first field is the CustomerID
00:30that's the AutoNumber ID field for our customers.
00:33If I try and type something here, I'll get a warning beep and a message down
00:37along the bottom that says that the Control cannot be edited;
00:40it's bound to an AutoNumber field.
00:42Access is going take care of the serial numbering of all of our customers for
00:46us, so that we don't need to keep track of that.
00:48I am going to tab to go to the next field, the FirstName field, and enter in
00:53Evan, our first customer.
00:56I'll press tab again to go the next field, this is our LastName field,
00:59his LastName is Santos.
01:01I'll press tab one more time to get to the Phone Number field and I am going to
01:06type in his Phone number, (383)835-9398.
01:09When you get done entering the record, you can press tab one more time or press
01:13the Enter key, to move down to the next record and we will start entering in
01:16our second customer.
01:18I'll skip the ID field, press tab again, this customer is Micah Harvey, and
01:24Micah's Phone number is (564) 618-7716.
01:29When you get done entering that record, press Return or Enter one more time.
01:33Our last Customer is Dante Levy and Dante's Phone number is (636) 920-1555.
01:44Now if you want to move back and forth between the records, you can press
01:46the arrow keys to move left and right, or up or down, to move around in your records.
01:52We can also use the button down here at the very bottom of our table to navigate
01:55through the records.
01:56Like I have options to go to the first Record here, or go to the Last record.
02:01I can move back and forth single records by pressing the Previous record button
02:05or the Next record button.
02:07In the middle here we have the Current Record indicator.
02:10This information tells me what record number we are on in the Table and how many
02:15total records there are on the table.
02:16Right now, it says 3 of 3.
02:18I'm on the third record of three records in this table.
02:22This last button over here with the yellow starburst will jump us to a new blank record.
02:26Now we only have three customers currently, if I wanted to add a fourth, it's
02:30really easy for me just to go to this fourth line and start typing it in.
02:33But imagine you have a table with 10,000 records in it, pressing this button as
02:37a shortcut, instead of having to scroll all the way to the bottom before you
02:40enter in your new information.
02:42We are going to talk about the Filter and Search boxes in a later movie.
02:46Now it's worth noting here that Access is saving all of these record
02:49entries automatically.
02:50As soon as we finish typing in one record and move to the next, Access saves
02:54that record to the database, so we never have to worry about losing data.
02:58The only time you need to save the database is when you're making changes to
03:02the structure of it, to the design of tables or forms or the connections, for example.
03:06Whenever you're strictly entering or modifying the data that lives in the
03:09database, you don't have to think about saving, your data will be safe and
03:13sound in the Access file.
03:15I can go ahead and close the Customers Table and you'll see that Access
03:18doesn't prompt us to save.
03:20If I double-click on it to open it again, you'll see that our records are
03:23there safe and sound.
03:24Now once your tables are created, entering data can be as simple as typing
03:27into the blank cells.
03:28Later in the course we will see how we can add additional controls on these
03:32cells to help prevent data entry error, such as typos and help automatically
03:36control formatting, such as automatically adding the parentheses around our area
03:40codes in phone number field.
03:42We also saw where to look to get some basic information about the contents of
03:46our table, such as the currently selected record and how many records it
03:49holds, down here.
03:52Anytime I open up a new table, my eyes instinctively flick down to this little
03:56box for quick and easy summary of the contents.
Collapse this transcript
Understanding primary and foreign keys
00:01In a well-designed database, you'll create many tables that relate back to
00:04records in other tables.
00:05If you have data that isn't specifically about the primary theme of the table,
00:09it's probably the case that it should go into another table.
00:12For instance, let's suppose we want to sort credit card information in our
00:16database; here's a couple of questions that you might ask in determining where to
00:19store the credit card data.
00:21Does the credit card number describe our customer? No, not really.
00:26Will every customer want us to remember their credit card number? Probably not.
00:30Will some customers have multiple credit cards on file with us?
00:33Yeah that's a possibility.
00:35So credit card numbers are not specifically about a customer.
00:38Some customers won't have any and some customers will have many.
00:42All of these answers lead me to conclude that customer credit card numbers
00:46should be stored in a different table from our customers.
00:49Let's create a new table to store a credit card information and then create the
00:53hooks to be able to tie it back to specific customers.
00:57From the Create tab I am going to go and press the Table button, I am going to
01:01add the field for Card Name, Card Type, Card Number, all of those being short
01:06text, and then we will add a field for Expiration Date, which will be a date time field.
01:10This first one, I'll double-click on ID and change it to CreditCardID, I'll
01:15press tab to go to the next field and press the T key to select short text from the list.
01:20This is our CardName field, I'll press tab again and press T again for
01:26another short text field.
01:28This one of our CardType, tab again, and T again, this is our CardNumber, tab again.
01:39This time I am going to choose the ExpirationDate, that's a Date & Time field, I
01:43can go down with the arrow keys or just press the D key to select the Date & Time
01:48field and this is ExpirationDate.
01:51We'll also need to create a way to tell us what customer this CreditCard belongs to.
01:56We could put a Name field, but what would happen if we have two customers
01:59with the same name?
02:00How will we know, which of them this Credit Card belongs to? This is why we have
02:05a unique primary key in each table.
02:07We can make use of them in other tables so that we will know exactly which
02:10customer each credit card belongs to.
02:12This is called the foreign key in the Credit Card's table, since it tells us who
02:16each CreditCards belongs to.
02:18Create an additional field named CustomerID, I'll press the tab key here, and
02:23this is going to be a Number field, so press the N key and type in the CustomerID.
02:29We can rearrange the position of our columns by clicking on the Name.
02:32I am going to press Enter to finish that, and then click on that field to highlight it.
02:38Now I can drag it to whatever position I want, typically a foreign keys might
02:42appear towards the beginning of our table, but it's not required.
02:45But I can click and drag to the left to reposition this field.
02:48I am going to place it right after the CreditCardID field.
02:52Also while we're here, we can realign the width of our columns, simply
02:56double-click on the edge between two fields to adjust the width of the column on the left.
03:01I'll double-click here, so that CreditCardID fills out and double-click here for
03:05CustomerNumber and ExpirationDate to make those fields wider.
03:10I am going to go ahead and save this table now by pressing the Save icon or
03:14pressing Ctrl+S on the keyboard and we are going to call this
03:17CustomerCreditCards.
03:19Once you get that typed in, press OK, and you'll a see it show up on the
03:22Navigation pane on the left.
03:24Now I'll start feeling in some information to see how the foreign key field works.
03:28Back in the Customers Table that we filled in the last movie, we put in three
03:32Customers, Evan, Micah, and Dante.
03:34Evan is CustomerID number 1, Micah is 2 and Dante is 3.
03:39Let's create some Credit Cards here in our CustomerCreditCards Table.
03:42I'll click back on the tab to switch back to the other Table.
03:46Now let's say Evan and Micah, that's our Customers 1 and 2, don't have any Credit
03:50Cards that they want to save with us.
03:52Dante, he's our Customer number 3, and he has two CreditCards.
03:55We will fill in the CreditCard Table like this.
03:58The first CreditCard will have a record ID on its own, this again, is an
04:02AutoNumber field that Access will take care for us.
04:05The CustomerID, this is who this CreditCard belongs to.
04:08This CreditCard belongs to Dante;
04:09he's our CustomerID number 3.
04:12I'll press tab to go to CardName, this is a business card, so I'll type the word
04:17Business here, the CardType is a Visa, and I just notice I have a typo here.
04:23So I'll double-click on CardTyle and rename it to CardType and press Enter, all
04:28right, so that's a Visa card.
04:30Let me go ahead and type in the CardNumber here 4826-0526-8582-0623.
04:40And I'll press tab to go to the next field, the ExpirationDate, and I could
04:43type in the ExpirationDate or I can use the calendar picker.
04:46Since this a few months out, I am just going to go ahead and type it 10/31/2013
04:52and press Enter to accept those changes.
04:54I am going to double-click on this line between CardNumber and
04:57ExpirationDate one more time to expand the width of that column to
05:00accommodate the entire CreditCardNumber.
05:02Now we are going to type in another CreditCard for Dante.
05:04CustomerID, well that's the same, it's still a CustomerID number 3.
05:09This time this is a PersonalDebit card, it's still a Visa card and it's got a
05:16number here and ExpirationDate for this card is 3/31/14.
05:23So notice that the structure is very flexible and efficient in allowing us to
05:26create one, many or no Records that are related to each customer.
05:30And the order that the cards are entered doesn't matter, if Evan, he's our
05:34CustomerID number 1, decides later to put in a card, that's completely fine.
05:38It can go anywhere in the Table as long as it is tied to his CustomerID.
05:42So let's put in one for Evan, CustomerID for Evan is 1, this is his airline
05:46rewards card, it's a MasterCard.
05:51The number here is 5275-6787-1289- 1613 and the ExpirationDate is 2/28/15.
06:02Adding foreign keys to your tables is just like adding any other field.
06:06The important point to keep in mind is that the DataTypes must match, this means
06:10that if you're using an AutoNumber field as the primary key in one table, then
06:14the foreign key in the related table must be a number field.
06:17As long as the data is the same, you can use 1 as a reference to look up
06:22information in the other.
Collapse this transcript
Importing tables
00:00If you already have information stored in a File such as an Excel workbook, you
00:04don't need to retype it to get it into Access.
00:06You can use the tools available on the External Data tab in the imported link group.
00:11You'll notice that we have lots of different file types that we can bring into Access.
00:15We can bring in Excel files, or Tables from other Access Databases, we can bring
00:20in Text files, which would include comma-delimited.csv files.
00:23We can choose XML and we have additional options here under the More button.
00:28Let's bring in an Excel file to replace the Customers table that we began to
00:32create in the prior movies in this chapter.
00:34The file we are bringing in has additional fields that we didn't create in the
00:38original, such as fields for the Address.
00:39Instead of creating those fields manually and then importing the data, we can
00:43create the entire structure and import the data in one step.
00:47I'll right-click on the Customers Table and choose Delete from the pop-up
00:50menu, Access will ask me to confirm that I want to delete this table, and I
00:55do, so, Ill press Yes.
00:57Now we are going to bring in the Excel file to replace it, back on the External
01:01Data tab in the imported link section, I am going to the press the Excel button
01:05here, make sure you are pressing the Excel button on the left half of your
01:07screen, not the Excel button that's in the Export group.
01:11We want to bring data in so stay over here in the left, press the Excel button
01:16and the Get External Data, Excel Spreadsheet Wizard starts.
01:19First, we need to tell it which file we want to bring in.
01:23I am going to press this Browse button and in the Exercise folder, in the
01:28Chapter 02 folder, we'll find the Customers Excel file.
01:32I'll press Open, now we get to choose what do we want to do with that file.
01:37We have three options, we can either import the Source data into new table in
01:41the current database, we can Append the copy of the records into a table if we
01:45already have one existing, or we can Link to the data source by creating a linked table.
01:50If we create this as a linked table, Access will be able to use the data that's
01:54inside of the Excel file, but it won't actually live inside of our database.
01:58If any changes occur to the Excel file, then those changes will be reflected
02:02inside of Access, however, if that file gets deleted or moved, then Access will
02:08lose track of it, so it won't be able find it.
02:10We want to bring the data actually and manage it inside of Access.
02:14So we are going to stick with the first option, Import the Source Data into a
02:18new table in the current database, go ahead and say OK and the next step of the Wizard starts.
02:22This top window is asking us which pieces of that Excel workbook we want to bring in.
02:27We can either bring in different worksheets, or if we have named ranges, we
02:31can bring those in.
02:32I am going to stick to Show Worksheets and choose the only worksheet that's in
02:35that file, the Customers Worksheet.
02:37It gives us a preview of what that data looks like down below.
02:40Go ahead and press Next.
02:42Now we can tell Access that the first row contains column headings, these are
02:45the field names across the top in the first row in the Excel file.
02:49I'll turn the checkbox on and the table updates to show that these are
02:52headers and not data.
02:54Go ahead and say Next.
02:55Now we can go through and choose the DataType for each field.
02:59Access is pretty good about selecting the correct DataType by the data that's
03:02already present, but we can click through to double-check.
03:05This first one, the ID field, is a double-digit data type, the next couple are
03:10all short texts, and I can scroll over to see additional data that's coming
03:14in from the Excel file, the State, Short Text and a ZIP Code that's also a short text.
03:19We can also choose if we have fields that we don't want to import, you can turn on the
03:23checkbox do not import those and skip it.
03:25We can also rename them if we would like.
03:28I am going to accept the names that came from the Excel file and I am not going
03:32to skip anything, go ahead and say Next.
03:34Now we get to choose how we want to add our primary key.
03:37We can let Access add a new column that's the primary key or we can choose an
03:42existing key if the ones are already there.
03:44I'm going to choose my own primary key and tell it to use the ID field, there.
03:49Go ahead say Next again, and finally, we get to name our table.
03:53Access is bringing in the name in the original Excel file, that's how it's
03:57knowing that this is customers. So that's great!
03:59That works for us, go ahead say Finish and Access brings that data into our Tables.
04:03If we go ahead and close this, I do not need with save the import steps, and
04:08we've got our new table that showed up here in the Navigation pane.
04:11If I double-click on it, we will see the results.
04:14So there are all of our fields we've got, and if I look at the bottom here, 200
04:18total customers that we just imported.
04:20We also imported the structure of this table, including, what we had created
04:23originally manually, the FirstName, LastName, and Phone fields, but also we have
04:27the Street, City, State, and Zip code fields as well.
04:31If you already have data set up in Excel, the Import tool makes it really easy
04:35to not only bring in that data, but also quickly create the entire structure of the table.
04:40Just choose the type of file you want to bring in, and let Wizard walk you
04:43through the options.
04:44At the end of the process you'll have your Table setup and ready to go, and if
04:48you already have the Table structure set up with some data inside of Access
04:51already, you can use the Append option in the Wizard to add data to an
04:55existing table.
Collapse this transcript
3. Setting Field Properties
Establishing relationships and maintaining referential integrity
00:00Once our data tables have primary and foreign keys established, we need to let
00:04Access know which fields relate to which.
00:07We can do this with the Relationships tool, you can find it in a couple
00:11of places, usually you are going to go to the Database tools tab and find
00:15Relationships here.
00:16If you have a Table open, I am going to go ahead and double-click on
00:19this Customers table.
00:20You'll also find under the Tables tools Conceptual tab and Relationships here.
00:26However, in order to modify or create Relationships between Tables;
00:30those Tables need to be closed.
00:32So even though you can get to Relationships through the Tables tab, it'll often
00:36create a situation where you can't edit it once you get there, because the
00:39original table is still open.
00:41So let's make sure our Tables are all closed by clicking the Close button over
00:45on the right side, and then going to Database tools>Relationships.
00:49The Relationship screen is essentially a blank canvas where we can layout a map
00:53of all of our tables and how they relate to one another.
00:56There is a new Contextual tab at the top called Relationship tools Design, here.
01:00We are going to press this Show Table Window to bring up a listing of all the
01:04tables in our Navigation pane.
01:07Let's go ahead and create a relationship between our Customers and their CreditCards.
01:12You can click on each Table here and press Add, or simply double-click to add
01:16them to Relationships map.
01:18I'll double-click on CustomerCreditCards and double-click on Customers and then
01:22have them back here to the Relationships.
01:24Then I'll close the Show Table Window.
01:27Now each of these boxes represents one of the tables from our database; this one
01:31is the CustomerCreditCards table; this one is the Customers table. Within each
01:36table, are all the fields and those are listed here.
01:39We can move these around by clicking and dragging on their tops or from the
01:43corner we can drag and make them resized.
01:45I am going to resize the Customer, so I can see all of the fields.
01:49I will resize this one as well, and then I will drag CustomerCreditCards and
01:53move it to the right side of Customers.
01:56To join these tables together, we are simply going to find the primary key in
02:00the Customers Table, which is this CustomerID and you can see the primary key
02:04icon here, and we are going to drag and drop it on top of the foreign key from
02:08the CustomerCreditCards table, that's the CustomerID field here.
02:13So I'll just click and drag, and when I get over the other CustomerID, I'll drop it.
02:18That will bring up the Edit Relationship screen, where I can confirm the fields
02:22that I dragged and dropped.
02:23If I missed for some reason, I can just click these dropdown menus and attach
02:28it to a different field.
02:29I am going to leave mine on CustomerID.
02:32We have got some options here;
02:33one very important option that you can get to on this screen is the Enforce
02:37Referential Integrity checkbox.
02:39When this is checked, Access won't allow you to create records in a table when
02:44the foreign keys don't match a record in the other table.
02:47In our example here, if I turn on Enforce Referential Integrity, Access won't
02:51allow me to input a CreditCard that isn't attached to a valid customer.
02:56It will also prevent me from deleting a customer while accidentally leaving their
03:00CreditCard Info in the database.
03:01In other words, it prevents orphan records.
03:05Records that don't relate to any parent info.
03:07This is a really great control to have on when appropriate, because it ensures
03:11that your database remains reliable.
03:13When Enforce Referential Integrity is turned on, you'll notice two
03:15additional options;
03:16Cascade Updates and Cascade Delete, these deal with situations when the data changes.
03:22If you change a primary key, then Cascade Updates will also make the same change
03:27to the foreign keys in all related tables. I'll turn that on.
03:31With Cascade Delete, Access will delete related records when the parent is
03:35deleted. In our case, if I turn this option on, then delete a Customer, Access
03:40will automatically find their CreditCard records and delete those as well.
03:44Both of these options make maintaining our database easy.
03:47I'll turn them both on and then press the Create button to establish the Relationship.
03:52You'll notice now that these two fields are joined by a line, on the left
03:57side, the Customers side, we will see the icon with a 1, on the right side
04:01we'll see an infinity symbol.
04:03This tells me that this is a one-to-many relationship.
04:05This is the most common kind of relationship you'll find.
04:09This says that every one Customer can have many different CreditCards.
04:14If a Customer wants to save hundreds or thousands of different CreditCards with
04:18us, no problem, we've setup our Database to handle that.
04:21Let's add an additional relationship between our Employees Table and the Related
04:24Phone numbers table.
04:26Here, I can go into the Show Table window to Open that again and click
04:31EmployeePhone and Employees and press Add to add those.
04:35I'll Close the Show Table window and I'll drag these fields around to line them
04:40up, so Employees and EmployeePhones, I can also enlarge them to make them
04:45bigger, so I can see all the fields.
04:47Now the EmployeeID matches the EmployeeID field here in the phone number.
04:52So I'll just drag, drop the joint line, I will Enforce Referential Integrity to
04:58make sure that we don't accidentally remove a customer, but leave their phone
05:01numbers behind and I'll press Create.
05:03Again, we get the join line between the two.
05:05Now I have got one more table that I want to join up here, that's the States
05:10Table, let me just open it up and we'll take a look at what's in here.
05:14The States table merely matches a state with regions within our company.
05:17That way if I attach this to our customers, we can start grouping our Customers
05:20together by region and not just a state.
05:22It gives us more information about the States.
05:25Let's close that down and we'll add that to our Relationship map as well.
05:29Now there is a shortcut here, I can actually just take the States Table and drag
05:33and drop it from my Navigation pane and drop it on the Relationships map.
05:38Now I just drag State from our Customers table and drop it on the
05:42StateAbbreviation field, which is the primary key for the States Table.
05:45We will create that join and we will move it back over here, just so it lines up properly.
05:51Before we end this movie, I want to share one common tripping point.
05:54The scrollbars on the bottom and right side of your screen indicate that the
06:00relationship map can be quite large.
06:02But sometimes if you accidentally click in one of these, everything disappears;
06:06it scrolls right off your screen.
06:08Oftentimes people will do this and will think that everything is deleted, but
06:11don't worry, everything is still there, you just might need to scroll all the
06:14way to the top and scroll all the way to the left.
06:17So that's how you establish relationships between tables.
06:20Anytime you create a new data table, you want to revisit the Relationships map
06:24to tell Access how the new table integrates with all of the others.
Collapse this transcript
Editing table structure in Design view
00:00All of the objects that we are going to be creating in Access have multiple ways
00:04to work with them. These are called Views and you can switch between the
00:08available views using the first button here on the home tab, here, Views.
00:13Let me open up the Customers Table to activate it.
00:17The Views button has two parts, the upper half will toggle between two default
00:21states. In the case of Tables that will switch between Datasheet view like we
00:26have now, and Design View here. I'll press it again to toggle back.
00:31The bottom half of the button will expand to show additional views if available
00:35for the object that you're working with.
00:37Now let's go and take a look at our Table in Design View.
00:40I'll switch to Design View, and we will see all the fields in our Table are
00:44listed down in a column instead of across the top.
00:47We can also see their DataTypes, which is the next column here, you'll see that
00:51all of our fields in our Customer Table are Short Text Data Types, except for
00:54the ID field, which is an AutoNumber.
00:56There is third column is where we can put in a Description of the type of
01:00data that goes here, this is a great place to store any notes or reminders about each field.
01:05It can be a very useful reference when you come back to edit your tables later.
01:09For instance, for our State I'm going to enter the Description Two letter
01:13state abbreviation.
01:16We can also add or modify fields that make up our Table here in Design View.
01:20In some respects, it's actually easier to create a Table in Design View than it
01:24is in Datasheet View like we did earlier.
01:26If I want to add an email field before a phone number, I'll simply click on
01:30the Phone number field,
01:32go up here to the Ribbon and press Insert Rows.
01:35That will insert a new blank row above the Phone or I could type in the field EMail.
01:42I'll press tab to select my DataType.
01:45Again, I have got a dropdown list just like in Datasheet View, and for this
01:49I'll choose Short Text.
01:50Finally, for the Description for this field, I'll enter customers
01:54primary contact email.
01:56Now we can switch our View to Datasheet View to see how that looks. Back on the
02:00Design tab, I'll press this View button.
02:02Access is going to tell us we need to save the Table first.
02:06So since we made structural changes, I'll Save that changes there and now
02:10it takes me back to Datasheet View where we see our new EMail field here,
02:14right before Phone.
02:15Let's go a head and go back into Design View.
02:17I'll go back, toggle that there and now we are back in Design View.
02:21The gray selection boxes to the left of each field are handles, and we can use
02:26those to rearrange the fields.
02:28So if want to move our email to the end, I'll simply click on that gray box and
02:32then click and drag to rearrange and I'll drag it to the bottom.
02:35Notice that we can also quickly identify the primary key field in this Table.
02:39It has the yellow key icon that we saw in the Relationships map.
02:42This is good information to know and is something that's not readily apparent
02:46when looking at the table in Datasheet View.
02:48If you don't have a primary key established for your table, there is a button
02:52here on the Ribbon to turn it on.
02:54So you just click on the field and you click on primary key to add that to that field.
02:58We are going to take a look at the Design View a little more in depth in the
03:03next few movies, including the bottom half of the screen, which deals with
03:06additional properties for each field.
03:07Now because changing our view is a very common task throughout Access, there are
03:11bunch of additional ways to do that.
03:13From the Navigation pane, you can right- click a Table, or any object, and choose
03:17to open them straight into Design View.
03:19The same applies to the objects Name tab, if it's already open, you can
03:22right-click and change your View here as well.
03:25You can switch it to Datasheet View for example.
03:28Again, Access it's going to ask me the Save changes, so I will and now I'm
03:32back in Datasheet View.
03:34Also if the object is open, on the first Contextual tab for that object, in this
03:38case under the Table tools group, this Fields tab, we will find a View button
03:43here and there is also additional little icons down on the bottom right corner
03:47of your screen over here, to change your Views there as well.
03:51So we have lots of options to toggle our Views back and forth between the working
03:55Views and the Design Views.
Collapse this transcript
Controlling input with masks
00:00Access databases give us lots of ways to control the input of data into the tables.
00:05This helps ensure that what we've entered is typed correctly and often more
00:08important, consistently.
00:11We can make use of the Input Mask Field property to help make sure that every
00:15time we enter a phone number for example, it gets formatted properly.
00:18I am going to go ahead and open my Customers table and I will open it in Design
00:22View by right-clicking on it and switching directly to Design View.
00:26Now for my Phone number field here, down in the Properties, we will see the
00:30Input Mask property here.
00:32When I click on it, we get a Build button way over here on the right side.
00:35These three little dots will indicate that we are going to build a property
00:39for this, and you will see this three dot convention in a lot of places throughout Access.
00:43Go ahead and press that button to launch the Input Mask Wizard box.
00:47Here we can choose from a list of predefined Input Masks.
00:50The Phone Number Input Mask is what we are looking for here.
00:53And down on the bottom we have a Try It box.
00:56What I want to do is click in the very beginning of that box and try typing in some numbers.
01:01You will see that it formats the phone number properly.
01:03Go ahead and back off of that.
01:05Let me try some different numbers.
01:06It puts in all of the parentheses, the spaces, and the hyphen in the right spot.
01:11Go ahead and press the Next button to accept the phone number property.
01:14Now we can edit the Input Mask if we choose.
01:16Access uses a little bit of code to help tell it what's valid and what's not.
01:20In this case the 9s indicate that it has to be a number, but that it's optional.
01:24The 0s indicate that it has to be a number, but it's required.
01:28We can also change the placeholder character down here.
01:31Currently it's an underscore (_).
01:32If I use the dropdown list, I can choose a different character, for instance,
01:36this pound (#) sign and now in the Try It box when I click down there, you will
01:39see that it gets placeholders and are shown up with a pound (#) symbol.
01:43Let's switch it back to the underscore (_) character and go ahead and press Next.
01:48Now we get to choose how we want to store the data in our table.
01:51We can store the data without the symbols in the mask, with just the numbers, or
01:54we can store the symbols in the mask with a parentheses and so on.
01:58I am going to choose to store the symbols.
02:00Go ahead and say Next and that's all the wizard needs.
02:03So we will say Finish.
02:04Access puts the Input Mask down here in our phone number field and we can go
02:08ahead and switch back to Datasheet View and test it out.
02:11Now because this is a structural change to the way the table functions, when I
02:14switch my view, Access is going to ask me if I want to save the table.
02:17So go ahead and say Yes, and now that change has been saved.
02:21I will go ahead and go up to our phone number field here and I'll just
02:23highlight this first one and I'll delete it, and we will try typing in those numbers again.
02:28383-835-9398.
02:32You can see that it puts in all of the punctuation properly, and I don't have to
02:35take my hands off the number keypad to type in the phone number now.
02:38Let's go ahead and create one more.
02:40I want to create an Input Mask that forces all of my state abbreviations to be capitalized.
02:45I don't want to have any lowercase state abbreviations.
02:47Let's go back into Design View to do that.
02:49I will switch to Design View here and for my State Field, I will go to the Input
02:55Mask property again, and click the build button over here on the right.
02:59Now if I scroll through this list of available Input Masks that are predefined,
03:02you won't see anything about state abbreviations in here.
03:05So what we can do is say Edit List to add it.
03:09The Edit List field shows up and it's set up just like Records in any other table.
03:14So you can see the Input Mask Wizard properties are set up like a table.
03:18I can scroll through the various predefined input masks or I can go to the very
03:21end to the blank record, which is number 5 here and put in my own.
03:25I am going to put in a Description here, State Abbreviations.
03:29The Input Mask here is going to be the greater than symbol (>) which indicates
03:33that everything I am going to type in is going to be forced to be uppercase and
03:37then I am going to put in two Ls.
03:40The Ls indicate that we are only going accept a letter.
03:42We won't be able to put in any numbers here.
03:45The next field is the Placeholder.
03:46This is what shows up we haven't typed anything.
03:49I am going to put in an underscore (_) character.
03:51Then down below Sample Data, this is the example of what the output will look like.
03:55So we can see it when we choose it from the list.
03:58I will type CA for California as our example.
04:00Go ahead and say Close to this, and you will see it now at the bottom of our list, there.
04:05Go ahead and select it. We will say Next.
04:08We can see the abbreviation mask here, our placeholder character there.
04:12We can go ahead and try it out here.
04:14Now you have to click at the very beginning in order for this to work.
04:16So I will go to the beginning and we will try typing in two letters, and you can
04:19see that they're forced to be uppercase.
04:22If I press Shift and type in those letters, that works as well.
04:26But if I back off and try typing in any numbers, it won't let me do that.
04:30So go ahead and say Next.
04:32We are going to, well, there are actually no symbols in this mask, so it doesn't
04:35really matter how we choose here.
04:38But go ahead and say Next anyway, and Finish.
04:41It inputs the mask down here at the bottom and now if I go back to my Datasheet
04:45View, again, we'll have to save the table.
04:48Now I will go ahead and try typing in my states again.
04:51It doesn't matter how I try typing them in, I can't get a lowercase letter here.
04:55Using Input Masks where appropriate is a great way to make sure that the data
04:58that gets entered into your database is consistently formatted in the same way
05:01no matter who sits down at the keyboard.
Collapse this transcript
Setting the default value
00:00When you have a field that will commonly contain the same information
00:03record after record;
00:05you can specify a DefaultValue to appear when entering the record.
00:09The default value will allow you to simply skip over that field while typing and
00:13it will automatically put in the most common information.
00:15Of course, if you'd like to change it, you can.
00:18The DefaultValue is simply a suggestion.
00:20Let's add one to our Customers Table.
00:22I'm going to right-click on my Customers Table and switch directly to Design View.
00:26For my state, let's say I want to add a Default Value of the State of California
00:31where most of my Customers live.
00:32I'll go down to the Default Value property here and click once.
00:36When I do that this Build button opens over here on the right.
00:39I'll click the Build button and now we'll start the Expression Builder.
00:43Here's what I'm going to type in what I want to my Default Value to be.
00:47I'm going to type ="CA" this is telling Access that I want to Default Value to
00:55literally be the letters C and A for California.
00:58We'll go ahead and say OK.
01:00And that Default Value will get populated down here.
01:03Now let's try it out, I'll Save the changes to my structure of the table here
01:07and switch into Datasheet View.
01:10Now I'll go down and add a new record by clicking the New Record button down here.
01:14You'll notice when I get down there, the state is already pre-populated with California.
01:19I can type in what I want for my values, and I'll just tab through these here.
01:23And when I get to the City I can type in what city I want, and when I press tab
01:28again, if it's California, great!
01:30Just press tab one more time to skip over that and keep going with the zip code.
01:33I'm going to press Shift+Tab to back up a little bit.
01:36Now let's say I want to enter in a different city and state, and now when I get
01:39to the state, if I want to do Texas for example, I just type in TX like I would
01:44normally, and then tab to go into the zipcode field.
01:46So however I want to do it, if I want to accept California, I can, if I need to
01:50change it, I can do that as well.
01:53Now while we are here in Datasheet View, I should point out that we can also
01:56set the Default Value by selecting a field, then going to the Table tools, Field tab here.
02:02I'll select the Default Value option here, and that also starts the
02:05Expression Builder.
02:07Adding Default Values to your Table Design is an easy way to speed up data entry, by
02:11automatically suggesting the most common values for a particular field.
Collapse this transcript
Establishing validation rules
00:00Validation rules allow you to control what data gets saved in the database.
00:04If you try and enter a value that isn't allowed by the Validation Rule, Access
00:08will display a warning and allow you to fix the problem.
00:11Let's put some Validation Rules into effect in our Employees table.
00:14First, I am going to double-click on the Employees table to open it up.
00:17Now in our Employees table we have a HireDate column here.
00:21I want to make sure that the dates that are entered are either today's date or earlier.
00:25I don't want to be able to enter in a date that's in the future.
00:27Let's scroll over to the right.
00:29We also have a JobRating field here.
00:31Our job ratings fall in the range of 1 to 5.
00:34I don't want somebody to be able to put in a 0 for example or a 10.
00:37So I am going to create Validation Rules to control the data entry on these two fields.
00:41We will do that by switching into Design View.
00:44Now for the HireDate field, I will click there.
00:47We've got these properties down here for Validation Rule.
00:50When I click in the Validation Rule property, the Build button shows up over on the right.
00:53I will click that to launch the Expression Builder.
00:57Here we are going to type in the code for our Validation Rule.
01:00We want the dates that are earlier or equal to, today.
01:03That will launch the Expression Builder.
01:04Here we are going to type in our Validation Rule.
01:07I will type <= and then the code to get today's date, which in Access is just
01:12the Date function, and an open parenthesis and then a close parenthesis.
01:16Go ahead and say OK and Access adds that rule down here in our property.
01:21The Validation Text line is a string of text that will show up if somebody
01:25enters an invalid record.
01:26This can be really a friendly message here.
01:28So I am going to type in Must be today's date or earlier, okay, so that's our
01:32first Validation Rule.
01:33Now we are going to add the one for JobRating here.
01:36I will click on Validation Rule and once again return to the Expression Builder
01:40by clicking the Build button.
01:41The Validation Rule for our JobRating is that we only want values that are
01:45greater than or equal to 1, and the less than or equal to 5 (>=1 and <=5).
01:51I will go ahead and say OK to accept that Validation Rule.
01:54This time I am going to leave the validation text blank.
01:57If you leave it blank, you just get a generic error message when somebody enters
02:00in an invalid record.
02:01So let me go ahead and see what those changes look like.
02:04We'll save the changes to our table by clicking the Save icon on the Quick
02:07Access toolbar, and then we will accept this messages here that says Data
02:10integrity rules have been changed;
02:11existing data may not be valid for the new rules. That's fine.
02:15Go ahead and say Yes and we will switch into Datasheet View.
02:19Now I am going to scroll over here and let's try and edit this HireDate here.
02:23Currently it says 6 January, 1998.
02:25Let's enter in a date in the future, 1/1/2213.
02:30If I try and press Tab to move off of that field, I get the error.
02:33Must be today's date or earlier. Okay.
02:37I can always press the Esc key to return to the last valid entry value.
02:41Now let's press tab to go over to my JobRating.
02:44If I try and type in a 0 and press Enter, I get a generic error message that
02:48says one or more values are prohibited by the validation rule.
02:51Save that and if I change it to 10, I get the same error message.
02:56Go ahead and say OK, and I will change it into something that's in the right
03:00range, like 5, and press Enter and it accepts that value.
03:03So Validation Rules can act as gatekeepers to make sure that you can trust the
03:07data that is saved in your tables.
03:09I would recommend that anytime you use a Validation Rule, you should always also
03:13put in a friendly reminder in the Validation Text property.
03:16It provides additional instruction to the person that is trying to type in the
03:19values into your table.
Collapse this transcript
Creating lookup fields
00:00A Lookup field allows you to select a value from a list when populating a
00:04table with information.
00:05Like Validation Rules and Default Values, this is another tool that you can use
00:10to ensure that the information in your Access database is valid and
00:13consistently entered.
00:14I am going to go ahead and open up our Employees table here.
00:17I've got a field called Status, and when I look through the table, I notice
00:21that I have four distinct categories of employees; Full-Time, Half-Time,
00:24Contracts, and Hourly.
00:26I want to turn this into a lookup list to help speed up the entry for new employees.
00:30I will switch to Design View to do this.
00:33I am going to go to my Status field here and take a look at a Lookup field here.
00:38Currently, it's set to Text Box.
00:41This allows me to type in a value.
00:42Access provides a wizard that will walk us through creating a Lookup list for a
00:46brand-new field, but unfortunately, it doesn't provide the wizard to convert an
00:50existing field into a Lookup list field.
00:52So for this example, I'm going to first create a duplicate status field using
00:56the wizard so that we can see what the options are, and then we will use that
01:00knowledge to convert the existing status field into a lookup.
01:03This way I won't lose the existing status information for the 700 plus employees
01:08already in the database.
01:09Now I am going go up to the ribbon in the tools group here.
01:12There is a button called Modify Lookups, but when I hover over it, the tool tip
01:16says Insert Lookup Column.
01:18This button might be named differently on your computer.
01:20I will click this button here and the Lookup wizard starts.
01:24We have two options.
01:25We can either choose to get the Lookup field values from a table or query or we
01:29can type in the values I want.
01:31I will go ahead and type in the values.
01:33Go ahead and say Next and now Access brings up a little table here where we can
01:37type in the values for our fields.
01:39Here we are going to type in Full-Time, Half-Time, Contract, and Hourly.
01:47We will go ahead and say Next.
01:48Now we can name our new field.
01:49I am going to call this, Status2.
01:51Notice that we have a checkbox to Limit to List.
01:54If we leave this off, we can choose from the list or type in whatever we want.
01:58I will turn Limit to List on, to prevent other values from getting entered.
02:02We can also choose to store multiple values, but that really doesn't make sense
02:06in this case, because an employee can't be two statuses at the same time.
02:10I will go ahead and say Finish to complete the fields.
02:13We will see we have a new Status2 field here entered right above Status and
02:17its Lookup properties have been changed to Combo Box, Value List, and here are our values.
02:23Let's go ahead and see how this works.
02:25I'll save the changes to the structure of my table and I will switch to Datasheet View.
02:30Now I have got the Status2 field and when I click there, it becomes a Combo Box
02:34where I can select a value to populate the list.
02:36I will choose the Full-Time here.
02:38Now let's take that knowledge back into Design View and we will convert our
02:41existing Status field into a Lookup list.
02:44I will go back to Design View.
02:46We will take a look at the existing properties for existing status field.
02:49I will click there.
02:50I will see the Lookup property is set to Text Box, but when I change that here
02:55to a Combo Box, I get all of the additional properties.
02:58So now we just need to copy over what we learned from the other field.
03:02Our Row Source Type, instead of Table Query, we are going to choose Value List
03:07and our Row Source, this is where we type in values we want to appear.
03:10I will type in Full-Time; (semicolon to separate the fields)
03:16Half-Time; Contract; and Hourly.
03:23I have some additional properties down below.
03:26Here is the Limit to List property we saw in the wizard.
03:29I am going to change that to Yes.
03:32I can allow multiple values.
03:34I will leave that to No.
03:36I can also Allow Value List Edits.
03:39If somebody tries to type in a new value and it's not in the list, Access might
03:43allow them to add it to the list.
03:45Here I don't want to allow them to add new values.
03:47So I will leave that to No.
03:48I will switch back into Datasheet View.
03:50We will save the changes to the structure and we'll take a look at the
03:53original status column.
03:55We will see all of our values are still there, but when I click on it,
03:58it becomes a Combo List.
04:00This will greatly speed up entry when we try and enter in a new employee.
04:04Now the only thing left is to get rid of this other duplicate Status2 field.
04:07One more time, back in Design View, I will select the Status2 field and I will
04:13press Delete Rows from the ribbon.
04:14It will ask me if I want to permanently delete them, and I will say Yes.
04:19Now my table is complete.
04:20I can close it and save the changes.
04:23So in addition to providing control over what gets entered, Lookup list can
04:26dramatically speed up data entry as well.
Collapse this transcript
Setting additional field properties
00:00There are a few other field properties available in Table Design View that
00:04are worth exploring.
00:05Let's take a look at them on the Employees table.
00:07I will open that up in the Design View, and the first one I want to look at is the EmployeeID.
00:13Right now it's set to an AutoNumber DataType, and has the Field Size of Long
00:17Integer and the New Values are set to Increment.
00:20Long integer fields store whole numbers only, no decimals, and include a range
00:24from about -2 billion to +2 billion.
00:28So we have plenty of space to grow with this field size.
00:30For a Short Text field like our FirstName, we can store up to 255 characters.
00:36If you know you only need a certain number of characters, you can make your
00:39database more efficient, if you specify a lower number.
00:42For instance, the State field in our Customers table only needs to store two
00:46letter state abbreviations.
00:47I can change the field size there to 2.
00:50If I leave it set at the default 255, Access blocks out enough space to store
00:55253 characters that I will never need.
00:59It does this for every single record.
01:01Setting it to 2 frees up that space making the database smaller and faster.
01:05The Caption properties will allow you to specify a header name that is different
01:09from the official field name.
01:11This can be useful when setting up forms as the labels that get auto created
01:15will use this caption, instead of the field name text.
01:18However, setting a caption here often just creates confusion down the line,
01:22since the true field name is essentially masked from view, which can make making
01:26references more difficult to set up.
01:29The Required property here allows us to force a field to be entered.
01:33Otherwise, the record won't be saved.
01:35The primary key field is always required, since it's the one field that keeps
01:39the database working properly.
01:41For this table I am going to set the FirstName and LastName fields to also be
01:45Required, because that's the minimal amount of information that I want before
01:48adding a new employee to the database.
01:50So I will set LastName to Required as well.
01:52We can also establish additional Indexes on the table here.
01:55Again, the primary key field is already indexed, but you can create
01:59additional indexes if needed.
02:01Having additional indexes on the right fields can help speed up searches and queries.
02:05Think about it like this.
02:07If I give you a phonebook and a person's name, you can quickly look up the
02:10person's phone number, since the phonebook is indexed by last name.
02:14However, if I give you a phone number and the same phonebook, imagine trying to
02:19find who that number belong to.
02:20You would have to search through every single line of the book to locate
02:24the correct person.
02:25However, if we had a reverse directory, essentially a phonebook that is
02:29sorted by the number instead of name, you'd be able to locate the phone
02:32number fairly quickly.
02:34Adding additional indexes is similar.
02:36However, the drawback is that every time you add a new record, all of the
02:40indexes have to be rebuilt.
02:41There is a definite tradeoff and you will have to experiment with your data
02:45tables and queries to identify the optimal number of indexes for your database.
02:49I am going to add an index here to the LastName field, since we will be
02:52searching by last name fairly often.
02:54I'll change this Indexed to No, to Yes, (Duplicates OK).
02:59The Date/Time DataType has a format property that's currently set to show a one
03:03digit day, a three letter abbreviation for the month, and a two digit year.
03:08We can make this a little more standardized by using this dropdown list and
03:11choosing from the available options.
03:13I am going to change it to show Short Date.
03:15I will start out with the slashes instead of those dashes.
03:18Now as you might have noticed as we have been clicking through these
03:21properties, over here on the right, we get a little bit of descriptive text
03:25that tells us what that property is, and if we want additional help, we can
03:29press F1 to go to the website.
03:31So while I am here in the Format property, I will press the F1 key on
03:35my keyboard to load Microsoft Help from the website, where we can get
03:37some additional help.
03:39You should continue exploring the properties for various DataTypes.
03:42Different DataTypes will have additional properties associated with them,
03:45and many are self explanatory, but I am going to admit that some of them,
03:49such as the IME Sentence mode may be so obscure that you will never have a
03:52reason to adjust it.
03:54However, if you ever have a question or like some additional resources on
03:57these properties, simply click in the box and press F1 to quickly get to the Help sheet.
Collapse this transcript
4. Organizing Records
Formatting columns
00:00Most of the text formatting that you will want to do will occur in form or report objects.
00:05After all, they are specifically designed for screen interface and printed output.
00:10However, there are some very basic formatting tools available when viewing your
00:13tables directly in Datasheet View.
00:15I am going to go ahead and open up the Customers table by double-clicking on it.
00:19Now I will select the FirstName Evan here and try changing it to Bold.
00:22I will press bold in the Text Formatting group on the Home tab.
00:26You will quickly see what happens.
00:28Even though we had just selected one cell, the change to a bold font applied
00:32to the entire table.
00:33In fact, this happens with most of these formatting options.
00:35I can turn Bold off, and try turning on Underline for instance, and you will see
00:40that everything becomes underlined.
00:41I will turn that off and try changing the font color here and everything turns red.
00:46Let's go ahead and use a dropdown list and change it back to Automatic.
00:50Here and there you might have a reason to do this, but most of the text
00:53formatting that you will want to do will be done inside the forms or reports later on.
00:58One formatting option that I've come across that maybe more useful is to color
01:01code tables using the alternate background shading here.
01:04I can use the dropdown list and select a color.
01:07For instance, I can color code by Customers tables blue and then I can color
01:12code my Employees table green.
01:14That way I have a visual cue when I am working inside each of them.
01:17One place where we can apply a different formatting in a table is when the field
01:21is a rich text enabled, long text data type.
01:24Let's add one to our Customers table.
01:27On the far right I will click here to add a new column and I'll choose Rich Text.
01:31I will give it the name Comment and press Enter.
01:35Now I will make that field wider by clicking on the bar between them
01:38and dragging it wider.
01:40Now I will scroll back, so I can see some of the other fields.
01:44I am going to enter in a Comment for my first customer.
01:47He is the winner of our Spring promotion and has a $50 credit.
01:51Now I can select individual words, for instance, I will select the second
01:54sentence and change it to Bold with a green font, and you can see that it
01:58changes independently of the rest of the words in the line.
02:01I mentioned before that this is a rich text enabled, long text data type,
02:05whichis quite a mouthful.
02:06You can see this more clearly in Design View.
02:08I will switch to Design View here and we'll take a look at that Comment field.
02:12You can see its data type is Long Text.
02:15Long Text is different from Short Text in that a Long Text field allows you
02:18to store over 65,000 characters, whereas, a Short Text has a limitation of 255 characters.
02:25If I look down at the Text Format property at the bottom, we will see its set to Rich Text.
02:30The other option is Plain Text.
02:32Plain Text won't allow you to set other formatting options with this line.
02:37So those are the settings that you'll need to know in order to style text
02:40inside of your tables.
02:41Keep in mind that Rich Text is only available in a Long Text DataType.
02:45As we move through the course, we will see other areas where text formatting
02:48will play a larger role in the styling of your Access database.
Collapse this transcript
Sorting table data
00:00A common task with any table of data is to sort contents to bring
00:04relevant records to the top.
00:06On the Home tab of the Ribbon, we have a Sort & Filter group here that holds all
00:10the tools to do just that.
00:12I will open up the Employees table to take a look at those options.
00:16Right now our records are in the order that they are put into the database, with
00:19the first record, Employee 1 at the top, and Employee 741 at the bottom.
00:25I can see that by clicking on the Last Record button down on the navigator, 741 there.
00:31I will click the first record to return back to the top.
00:33I can sort these records based off of any field that I choose however.
00:37To put them alphabetically by LastName, I will click on any cell in the LastName
00:40field, or I can select the entire column by clicking on the header row.
00:44Then press the Ascending button to sort A to Z or the Descending button to sort Z to A.
00:51Notice the tiny arrow icon that appears on the header row here.
00:55That's your indication that the table is currently sorted based off of that field.
00:59I can then click Remove Sort here to reset the table to its original state.
01:05These options are also available in the menu when you click on a header.
01:09If I click on the dropdown here, we'll see Sort A to Z or Sort Z to A.
01:13Sorting on Department will allow us to group everybody based off of their department.
01:19I will choose Sort A to Z.
01:21Now all of my Account Managers are together, and if I scroll down, we'll find
01:25everybody in the Creative Department, and the Environmental Department.
01:29I will press the Remove Sort button again to return the table to the
01:32default state once again.
01:33This brings up a couple of important conceptual points that I'd like to
01:36mention about records.
01:38Remember that records, that is, the horizontal rows in your data tables,
01:42represent a single entity, thing, or event.
01:45Each cell in a row goes with the others in that row.
01:48It wouldn't make any sense to mix them up.
01:50So when I sort these fields, wherever Tate goes for example, Zachary will go with it.
01:57They move up and down in the sorting order together, moving as an unbreakable unit.
02:01In Access, there is no way to break that functionality, and accidentally sort
02:05a column one-way and lose the relationship to its adjacent information in the other columns.
02:10The other important concept here is the idea of a record's position in a table.
02:14Right now, Zachary Tate is record number 1 out of 741.
02:19I can see that by glancing down to the current record indicator at the bottom of the screen.
02:24Now it's record number 1 because it is in the first position in the sorting
02:27scheme, not because of its employee ID number 1.
02:31A record's position in a table is a very transitive thing.
02:34Anytime we talk about a record's number, we really mean, in the sorting order
02:39this is record number 1.
02:41That's one of the main reasons why we use a primary key.
02:44When I say Employee ID 1, I will always be referring to Zachary Tate here,
02:49regardless of how the table is sorted.
02:51When I say record number 1, it can refer to any number of records depending
02:55on how they're sorted.
02:57It's an important distinction that will come into play more as we move on to
03:01explore the other objects that make up an Access database.
03:03Sorting our records provides an easy way to bring some alternate organization
03:07to the data tables.
03:08You can use it to group like values together, such as our building or
03:11departments, or provide alphabetized directories, based off of names of people or products.
Collapse this transcript
Filtering table data
00:00The filtering options on a table allow you to limit the number of records on
00:04screen to only those of interest.
00:06Just like the Sorting, this allows you to quickly get to the information that you need.
00:10I'll open the Employees table again by double-clicking on it and this time we
00:14will use the Filtering options in the Sort and Filter group here.
00:18We want to identify just the employees that work in the IT department.
00:21The easiest way is to find a record that matches what we want to filter by
00:25and select that field.
00:26I'll go ahead and choose somebody in the IT department here record number 19,
00:32Garrison North, then on the ribbon, we have a group of tools to filter based off
00:36of the selected cell.
00:38We can choose Equals "IT", Does not Equal "IT", Contains "IT" or Does not contain "IT".
00:44I'll choose Equals "IT" to filter my records.
00:48If I look down the bottom, here I can quickly see that I've got 44 records in
00:52this view of the data and here's another a visual button to indicate that we are
00:56currently looking at a filtered list of our data.
00:59In fact this is a toggle I can click on a Filtered button, to toggle between a
01:03Filtered and return to the Unfiltered state of my data.
01:06We can continue to filter down even further.
01:08For instance, I can choose somebody in the West building such as Chris Bauer
01:12here and then filter again based off of this to get a quick look at just the IT
01:18people in the West building.
01:19Again looking down the bottom of my screen I can see we have total of six
01:23people in this group.
01:24If you want to filter based off of multiple criteria for each field we can
01:28use the menu attached to the header of each column to select from the available data.
01:32Simply place the check box next to the values that you want displayed.
01:35So in addition to the IT department, let's scroll down and choose Product
01:40Development as well, I'll go ahead and say Ok.
01:43Now looking at the bottom, I can see I have 10 employees that are in the West
01:48building that are either in Product Development or the IT Departments.
01:52For a quick exploration of your data, a filter can bring up just what you need in a hurry.
01:56While you can toggle between Filtered and Unfiltered states of your data, there
02:00is no way to save multiple filters and move back and forth between those.
02:04At first this might seem like it will be a very useful feature in an obvious
02:08oversight but rest assured, you'll see why this is when we get to exploring query objects.
02:13While you can filter your data here inside of a table directly, queries really
02:17do take that functionality to the next level.
Collapse this transcript
Searching and replacing values
00:00No text editing environment would be complete without an easy way to search
00:04through all of the text and make replacements.
00:07Access is no exception and we can use the same Find and Replace tools that you
00:11may be familiar with from other Office programs.
00:14On the Employees table, we can locate specific records quickly and easily using
00:18the Search box at the bottom of the screen.
00:22For instance I'll type Green here to quickly find Kim Green's record.
00:26But what if I want to find additional records?
00:28Well, you can just keep pressing the Enter key to cycle through all the matches.
00:32We will find people at work in the Green Building Department and if I keep
00:37pressing Enter I'll find Alexander Greene spelled with an E at the end of his name.
00:42An alternative option is to go up on to the Ribbon and click on the Find button
00:46up here with the big binoculars icon, that'll bring up the Find and Replace
00:50tabs, on the Find tab I can type in what I'd like to find.
00:54I have additional options of where I want to look either in the Current field or
00:58the Current document or how I want to match.
01:02Any part of the field, the Whole field, or the Start of the field.
01:05If I change to Whole field and press Find Next, it only find's Kim Green's record.
01:11If I press Find Next again it won't find any other records, it won't locate the
01:16Green Building Department and it won't find Alexander Greene spelled with an E,
01:21go ahead and say Ok.
01:22The Replace tab of the Find and Replace dialog will go through our entire
01:26table and replace text.
01:28That makes it very easy to change a lot of data at once.
01:31I've noticed that in the Status field over here on the right, that my Half-Time
01:35employees are spelled with a hyphen.
01:37I want to standardize this to just a space.
01:40I'll use the Replace tab of the Find and Replace dialog box to do just that.
01:44I'll type Half -Time with a hyphen in the Find What field and then in the
01:48Replace With, I'll type Half Time with a space, I am going to search through the
01:52entire document and we are going to match the entire field.
01:55I'll press Find Next and Access will find the first occurrence, I can then press
02:00Replace to replace it and move to the next one.
02:03I can continue pressing Replace to cycle through, replacing those texts or I can
02:08press Replace All to process the entire column.
02:10Access warns me that I won't be able to undo this replace operation, once I do
02:14this change, it's made permanent in the table.
02:16I'll go ahead and press Yes to process the column and I'll see that all of my
02:20statuses are now updated without a hyphen in the half-time fields.
02:24The Find and Replace tools make it a snap to locate specific records as well as
02:28edit out common inconsistencies in the data.
Collapse this transcript
5. Using Queries
Understanding queries
00:00Queries are temporary looks at your data that are constructed from the records
00:04and fields stored in your data tables.
00:06A Query is literally a question that you ask of the data, and the result is
00:10returned as a temporary datasheet called a record set.
00:13Record sets merely display data they don't store it permanently, this means that
00:17when your tables update the query record sets update.
00:21There is no need to update the data in two or more locations.
00:24Further, the record set functions just like any of your other tables when
00:28feeding records to a form or report or even, in fact, to another query.
00:32On the surface, and as far as the other database objects are concerned, they
00:36are tables, but as we'll see they're simply pretending to be tables.
00:41The problem is, is that the tables we've created in Access are very efficient in
00:45storing data, but it also seems a little counterintuitive, when it comes time
00:49to actually finding information spread between lots of tables.
00:53If for instance, we needed to quickly find Robert Acosta's emergency contact
00:56phone number, we first need to look up his employee ID, then take that
01:01information to the phone table and then find his employee ID there and
01:04finally get the number.
01:06If you have hundreds or thousands of phone numbers to look up for a human
01:09sifting through these tables that could be a lot of work.
01:12Luckily we have Query objects to do all that for us.
01:15Queries bridge related tables back together in whatever configuration we might need.
01:20To create a Query we simply need to write out some basic instructions on how
01:24to assemble the data.
01:26Imagine that you take your data tables and you smash them all apart.
01:29Every field is now its own building block.
01:32When you create a Query, you essentially cherry pick which fields you want to
01:35pick up, which fields you want to ignore and in what order to snap them to
01:39back together again.
01:40The only space that queries take up in the database is just enough to store a
01:44few lines of simple instructions on how to reassemble your data.
01:48Regardless of how many records those tables contain.
01:50And that's just the most basic thing that they can do for you.
01:54Needless to say Queries are very powerful component of your Access database, and
01:57the wizards and design tools make it easy for you to harness that power.
Collapse this transcript
Creating queries with the Simple Query Wizard
00:01As with many of the objects in Access, the easiest way to get started with
00:05queries is to have the wizard walk us through some of the steps.
00:08Before we get started, let's have a goal in mind.
00:11Let's first take a look at the existing data tables.
00:14Our EmployeePhone list is setup as a table that is related to the Employees table.
00:17If we take a look, we can see an EmployeeID field here that is the foreign key
00:22that matches the primary key in the Employees table.
00:26This phone table tells me that the first three records here all belong to the
00:30same employee, number 635.
00:33But it doesn't tell me who that employee is.
00:35Instead of looking this information up manually, we can use a query to
00:38reassemble it for us.
00:40Let's go ahead and close this EmployeesPhone table.
00:42I am going to go to the Create Tab here and we'll create a new query using the Query Wizard.
00:47I will start the wizard.
00:50We're going to do a simple query, so go ahead and say OK.
00:54And the next screen that opens up asks us which tables are we going to use as the
00:58basis for our query.
00:59We had already selected the EmployeesPhone table over here in the navigation
01:03pane, so that's the first table that it suggests.
01:06I am going to actually use the Employees table first, because I want my names to
01:09appear at the beginning.
01:10I will choose FirstName, and I am going to use this arrow button to move it over
01:16from the Available Field side to Selected Fields.
01:18I will do the same thing with LastName.
01:20Make sure it's highlighted, and then press this arrow to move it over to select it.
01:24Now if I wanted to move all of the fields at once, I could use this double-arrow.
01:28If I wanted to undo that and move everything back, I can use this double-arrow
01:32to move them all back from selected to available.
01:35And if I just want to move one field back, I would use this button here to move
01:39it back to the other side.
01:41So I am going to make sure that I have FirstName and LastName.
01:44We also want to pull in the related records from the phone table.
01:47So I will go back up to the dropdown and choose the EmployeePhone table.
01:51There, I want to know the phone number, and the type of number that it is.
01:55Go ahead and say Next.
01:57Access asks us if we want to show details or a summary.
02:00We want to show every field of every record, so go ahead and say Next, and we
02:04can go ahead, and give it a name here.
02:07Employees Query doesn't really describe what this is, so I am going to call this
02:10EmployeePhoneNumbers.
02:11Finally, we have the option to choose whether we want to open the query, or go
02:15into Design View to continue editing.
02:16I am going to choose to 'Open the query to view the information', and press Finish.
02:22Access returns the query results, and we can see now that the first three phone
02:26numbers all belong to the same person, Zachary Tate.
02:29Now additional summary options are available when numeric data is included in the query.
02:33Let's get a query that summarizes our data instead of displaying every record.
02:36I am going to close the results of our EmployeePhoneNumbers query.
02:40If I needed to get it back, you will notice that it's here in the Navigation pane.
02:44This time I am going to create a query that takes a look at our products, and our orders.
02:48I've got two new tables here. The Products table, if I open that,
02:51you will see that it includes all of the products that NoObstacles carries.
02:55I will go ahead and close that table.
02:57The Orders table has a list of ID numbers that match customer IDs to the product IDs.
03:04It has a listing of the dates that the product was ordered, and the quantity
03:07that the products was ordered. Go ahead and close the Orders table here.
03:10We're going to create a query that summarizes that information.
03:14We'll go back up to the Query Wizard, a simple query, go ahead and say OK.
03:21This time I am going to choose the Products Table, and from that, I want to know
03:26which products were ordered.
03:28From the Orders table, I want to get the quantity that has been ordered
03:33from every customer.
03:35We'll add that to the selected fields, go ahead and say Next.
03:39This time, instead of showing every field of every record, I am going to
03:42get some summaries.
03:43We'll click the Summary and then Summary Options.
03:45I will choose to add up all of the quantities of every product, so that I can
03:50get a listing of the total ordered for each product.
03:53Go ahead and say OK, and Next.
03:57Finally, we can give this a name.
03:58I am going to call it TotalProductsOrdered.
04:01Once again, I am going to choose to open the query to view the information,
04:04and we'll press Finish.
04:06Now I've got a listing of all the products that we sell and the total number of
04:10products that have been ordered throughout the company.
04:13The Query Wizard can help you quickly get up to speed constructing some basic queries.
04:18For even more control and options, we need to take a look at the query design
04:21environment and we'll do that in the next movie.
Collapse this transcript
Building queries in Design view
00:00The Query Designer is a very powerful tool to have at your disposal, and it's
00:04layout makes it easy to find the answers of some very complex questions.
00:08The easiest way to begin exploring the query design environment is to take a
00:12look at an existing query, and see how it was put together.
00:15We'll use the EmployeePhone list query here that we created in the last movie.
00:19I am going to right-click on it and open it in Design View.
00:22Now the query design environment is split into two sections.
00:27The upper-half of the window is essentially a mini relationships map.
00:30It shows us the tables that are involved in building our query.
00:33We've got the Employees table, and the EmployeesPhone table.
00:37We can also see how they're related based off of the EmployeeID field here and here.
00:41The bottom-half of the window describes all of the columns that go into
00:45creating our query.
00:46In this particular query, we have the FirstName column, the LastName column, both
00:50of those coming from the Employees table, we also have the Number column and the
00:54Type column, coming from the EmployeesPhone table.
00:58We can rearrange this window a little bit if I want to give more room to the top-half.
01:02I will click on this bar here, and drag down.
01:04If I want to give more room to the bottom-half, I will click and drag up.
01:08So this is essentially what the Query Wizard built for us.
01:10Let's construct it on our own using a blank Query Design environment.
01:14I'll close this query out.
01:17I am not going to save any changes to it, and I will go to the Create Tab and
01:21select Query Design.
01:24Access starts up the Query Design environment, and it gives us this Show Table
01:28window just like when we built our relationships.
01:30From here, I can choose which tables I want to be involved in the query.
01:33I will choose EmployeePhone and press Add, and then choose Employees, and press Add.
01:39Then I will close the Show Table window.
01:42We can rearrange these tables however we like.
01:44I am going to take EmployeePhone and move it to the right, and I'm going to open
01:48up the Employees table just a little bit.
01:50I will move this window up to give me more room at the bottom.
01:54Now I just need to take the fields from our tables, and move them down into the query grid.
01:57We're going to build our query using the FirstName, and LastName from our employees.
02:03Now I can click and drag FirstName and drop it into the first column.
02:07A shortcut way to do this is to just double-click.
02:09I will double-click on LastName to add it to the next column.
02:13Our third column is going to be the Number from the EmployeePhone table, I will
02:17double-click on that, and then we're going to add Type.
02:20I will double-click again.
02:22At this point, this query is exactly the same as what the Wizard built for us.
02:26We can check it out by running its datasheet here to see the results. And there we go.
02:31Let's go ahead and switch back in the Design View.
02:35We can do a couple of additional things here in the Design View that the Query
02:38Wizard didn't allow us to do.
02:39For instance, under the Sort row here, we can choose to sort our results based
02:45off of, for instance, LastName.
02:46I will click and choose to sort ascending.
02:49I can also choose to show or hide particular fields.
02:52By default, it's going to show all of the fields that you've added.
02:55But if for some reason you want to turn one off, for instance you want to add it
03:00just to sort but you don't need to necessarily see it, you can uncheck the Show
03:03checkbox and that field will not display in the query's record set.
03:06I will go ahead and turn this back on.
03:08We can also rearrange the columns once they've been put down.
03:11In order to select a column, there is this gray bar at the very top.
03:15When you hover your mouse over, you get a downward pointing black arrow.
03:18Just click there to select it, and once it's selected, you can click and drag to
03:22move it to a different position.
03:24I will click and drag LastName and move it to the beginning of my query results.
03:28Each half of the screen also have their own set of independent scrollbars.
03:32Often times these scrollbars can accidentally get clicked, and it will look like
03:36your fields became blank again.
03:38So make sure that your scrollbars are always to the left, and to the left and
03:41top in the upper-half of the window.
03:43Finally, let me point out a really important distinction between these two
03:46buttons in the upper left-hand corner of your screen;
03:48the View button and the Run button.
03:51For most of the queries that we're going to create, they're considered Select Queries.
03:54They simply pull records out of your data tables.
03:57And for those, it doesn't really matter which button you press.
04:00Viewing the datasheet and running that query are exactly the same;
04:04they both display the query's record set.
04:07I will go ahead and switch back to Design View.
04:09The only time these two buttons differ is when we're looking at Append Queries,
04:13the Make Table Query, the Update Query or the Delete Query.
04:16These are all of the action queries, and you can see the same exclamation
04:20mark in their icon.
04:21When you run these query types, which we'll talk about in later movies, those
04:25actually make changes to your database.
04:27So when those queries are active, the View button and the Run button are very different.
04:32But like I said, for the select queries that we create, either one of these
04:36buttons will both display the records data sheet.
04:39We're going to continue working in the Query Design View throughout this chapter.
04:43There are a lot of options to explore and some really cool ways that we
04:46can organize our data.
04:47But they will all start with the same basic model.
04:50We will start with the tables to pull the information from up top, and then add
04:54the individual fields that will be combined into the final datasheet down below.
Collapse this transcript
Establishing constraints with criteria
00:00In addition to gathering and displaying records from data tables, we can add
00:04filtering constraints to the query design grid to only display the exact records
00:08we're interested in seeing.
00:10Let's see how this works by exploring the data we've collected for
00:12NoObstacles customers.
00:14I want to start a new query in Design View by going to the Create Tab and then
00:18pressing Query Design.
00:20In the Show Table window, I am going to choose a couple of tables.
00:24I'll choose Customers and I am going to double-click on the States table to add that.
00:28Go ahead and close the Show Table window, and now we need to populate the grid
00:31down below with fields from our tables.
00:34Let's go ahead and open up the Customers table a little bit so we can see all of
00:36the fields, and I will just move this over a little.
00:40From the Customers table, we're going to choose the FirstName, I will
00:43double-click on that, double-click on the LastName to choose that, our phone
00:47number, the state that they live in.
00:49And then from the related States table, I'm also going to get the RegionName.
00:53I will double-click on that to add that to our grid.
00:56Now let's go ahead and take a look at where we're at.
00:58I am going to run the datasheet by clicking on the View button here, and
01:02we'll see the results.
01:03We've got each customer, their first and last name, their phone number, the
01:07state they're in, and then the region that state belongs to.
01:10Let's go ahead and switch back to Design View.
01:12Now we can add filtering criteria using this Criteria row down in the design grid.
01:17For instance, if I'm only interested in the people that live in New York State,
01:21I can go to this Criteria row and type in NY and press Enter.
01:26Access wraps that in quotation marks which is the exact syntax that it needs.
01:30I will go ahead and run my datasheet again here, and we'll see our query record
01:35set is filtered to just the customers that live in the state of New York.
01:38Let's go ahead and switch back to Design View.
01:41I can change this up by typing in CA for California.
01:44This time I will type the quotes myself; 'ca'.
01:49Go ahead and view those results, and you can see that I have a lot of customers
01:53from California, I've got 18 by looking down here at the bottom.
01:57Go ahead and go back to Design View.
01:59I am going to delete this criteria here for State, and let's go over to the Region column.
02:04Let's add-in a region for Midwest.
02:08I will press Enter and go ahead and view that record set.
02:12We've got a total of 49 customers that live in the Midwest region.
02:16Now what happens if we type in a query criteria that doesn't exist in our database?
02:19I will go into Design View.
02:21And instead of Midwest, I am going to type Europe, which is a region that I know
02:27does not exist in the database.
02:29Let's view that record set.
02:30Now you might be surprised that we didn't get any errors.
02:33But if you think about what Access is telling us here, this actually
02:36makes perfect sense.
02:37We asked our database to show us all of the customers that were in the European region.
02:42Well, here they all are.
02:43We don't actually have any, so Access shows zero matches.
02:47There is nothing wrong with the question at all, and this is the correct answer
02:50to the question that we asked.
02:51Let's go back into Design View and change Region back to West.
02:56I will go ahead and run the record set one more time, and then we'll save these results.
03:01I will click the Save button to save our query, and I am going to call this
03:05Customers-WestRegion and press OK.
03:09Now let's add one more change.
03:11I am going to go back in the Design View, I am going to change this Region from
03:15West to Midwest, run it just to make sure I get results, and I'll save that
03:21again, but I am going to save it with a new name.
03:23For that, I will go to the File Tab, go to Save As, and then Save Object As
03:28to create a duplicate.
03:29I will press the Save As button here, and now we'll give it a different name.
03:35Instead of Copy of Customers in the WestRegion, we'll call this
03:38Customers-MidwestRegion.
03:41Go ahead and say OK and that takes us back to our standard interface.
03:45And now you can see we have two queries here;
03:48Customers-MidwestRegion, and Customers-WestRegion.
03:48I will go ahead and close the query down.
03:51And anytime we want to view our people from the Western region, we just run
03:55this, anytime we want to see our customers from the Midwest region, we'll run this one.
03:59The Criteria row of a Query Design View allows you to quickly and easily filter your data.
04:04Unlike adding filters directly to your data tables, you can save your query
04:08in any number of configurations and have lots of different filters applied to the same data.
Collapse this transcript
Specifying criteria with wildcards
00:00Adding wildcard characters to your query criteria is perfect for those times
00:04when you want to filter your data based on a common pattern rather than an exact match.
00:09Let's create a new customers query to see how wildcards work.
00:12From the Create Tab, I'll press Query Design, and I'll add a Customers table to
00:17the query grid, and close the Show Table window.
00:20From here, I'll add the fields FirstName, LastName, Phone, and I'll scroll
00:26down, and get State.
00:29Now let's assume that we want to break this list up by LastName.
00:32We have seen how we can simply add the name we want to the Criteria field.
00:36For instance, underneath LastName, I'll type 'harvey'.
00:40If I run this query, you will see that we have three customers with the
00:44last name of Harvey.
00:45Let's go back into Design View.
00:48But what if you wanted all of the customers that have the last name that starts with H?
00:52The most common wildcard character that you will probably use is the asterisk
00:55(*) character or Shift+8 on your keyboard.
00:58The asterisk character is a placeholder for any character and any number of characters.
01:02We can use this to specify criteria, it displays all of the customers that begin
01:06with h by changing our criteria here from harvey to h*.
01:11When I press Enter, Access updates the query to read it Like 'h*' with the h*
01:17in quotation marks.
01:18This is simply saying that, instead of exactly matching this text, we want the
01:22records that are like this pattern.
01:24It's probably best to get used to this syntax and just type it in the way
01:27that is required rather than relying on Access to understand your intent and fix it for you.
01:32Sometimes, Access doesn't get it quite right when it tries to auto-correct.
01:36Now when we run this query, we'll see our 22 customers that have last names
01:41that start with the letter H.
01:43Let's go ahead and switch back into Design View, and we'll mix it up a little more.
01:47Another wildcard character at our disposal is the question mark (?).
01:50The question mark character stands for any single letter or number.
01:54Change the criteria to 'h???' and press Enter.
02:00Again, Access updates our syntax and now when we run this query, we'll get
02:05only our customers whose last name starts with h, and has a total of four
02:09different characters.
02:11I'll run it, and we'll see that we only have two customers that meet this criteria.
02:14Let's go ahead and switch back into Design View again.
02:17We can also specify a character list as a wildcard.
02:21Simply enclose the list of characters to match inside of square brackets.
02:25Here is an example where Access won't autocorrect our syntax for you, and add the Like.
02:29Go ahead and type in here instead of Like 'h???', type-in [abc]*.
02:39Here our intent is to gather all of the last names that either begin with A, a
02:44B, or a C, and then any characters after it.
02:46But you will see when you press Return, you get an error message that Access
02:50doesn't understand what you're trying to do.
02:52Go ahead and say OK, and at this point, we'll add in the Like operator manually.
02:58I'll press the Esc key to back out of it, and now I'll just type Like,
03:03space, quotation mark.
03:05Now I will type-in the square bracket abc, closing bracket, asterisk, and a
03:10closing quotation mark.
03:12Now when I press Enter, there aren't any error messages, and we can run our
03:16data sheet to see the results.
03:18We'll see all of our customers whose last names either begin with an A, a B, or
03:22a C, and looking at the bottom, I see that I have a total of 47 customers that
03:27meet these criteria.
03:28Adding wildcards to your query criteria can make filtering very effective when
03:33there is a pattern to the records you'd like returned.
03:35Simply use the asterisk to specify any number of characters, the question mark
03:39when you only want one character, or a character list in square-brackets when you
03:43want to match specific characters.
03:45And remember to include the Like operator to keep Access from misunderstanding your intent.
Collapse this transcript
Leveraging multiple criteria with AND and OR statements
00:00Adding multiple query criteria to filter your records can be accomplished in a
00:04couple of different ways.
00:06Let's create a query that explores our employees' data, and uses
00:09multiple filtering criteria.
00:10I am going to create a new query in Design View by going to the Create Tab>Query Design.
00:15From there, we'll add our Employees table.
00:19And from the Employees table, we'll choose FirstName, LastName, Department, and Status.
00:28If we add multiple criteria on the same line, Access treats them as a
00:32logical AND statement.
00:34Let's try adding manufacturing to the criteria row under Department, and we'll
00:38add Full Time in the Criteria row under Status.
00:42Notice that when I typed in Full Time, Access started thinking that I was typing
00:46in the function called Time.
00:48That's not really what I want.
00:49So I need to make sure that I include the quotation marks on my own.
00:52I'll press Backspace a few times.
00:54And this time, I'll type in the quotation marks, 'full time'.
00:59Now I can press Enter, and that works out fine.
01:01Let's view our datasheet to see the results.
01:03I'll click on the Datasheet button here.
01:06We'll see we have a total of 80 employees that are both in the Manufacturing
01:10department, and that are a Full Time status.
01:13Let's go back into Design View.
01:16You will notice that the line below Criteria says 'or'.
01:20In fact, you can think of every line below as also 'or' lines.
01:23When you place multiple criteria on these lines, Access returns the logical
01:27combination of the two criteria.
01:29So if we move Full Time from this line up here, I'll just delete over that,
01:35down, and move it to the 'or' line here, remember to type-in the quotation
01:38marks, 'full time', quotation mark.
01:40If I run this query, we'll see a different result.
01:43Now I get a total of 464 employees that are either in the Manufacturing
01:48department, or that are Full Time, or possibly both.
01:53Let's switch back and explore a little further.
01:55Go back into Design View.
01:57What happens if we want to display two criteria on the same field?
02:00Well, we can use the 'or' line in this case as well.
02:03Let's remove the Full Time criteria here, and underneath Manufacturing, I am
02:08going to type quality assurance.
02:11Now I'll run the query, and we'll see just the employees that are in the
02:14Manufacturing or Quality Assurance departments. All right.
02:18Go back in the Design View.
02:20There is a shortcut to writing that out on a single line using something
02:23called a Logical Operator.
02:25But it includes a common tripping point.
02:27Often, you'll think to yourself something along the lines of, I want to see all
02:31the employees in the Manufacturing and Quality Assurance departments.
02:35If you go to the criteria line and type that out, I'll delete Quality Assurance
02:38here, go back up above where it says Manufacturing, and after that, I'll type
02:43out 'and', in quotation mark, 'quality assurance' and press Enter.
02:48If it's too long, you can enlarge the field by clicking and dragging here.
02:52So now it reads 'manufacturing' And 'quality assurance'.
02:56Let's run that data sheet.
02:58This time, I don't get any results. So why is that?
03:00Well, if we think it through, you will realize that you've actually asked for
03:04all of the employees that are in both departments at the same time.
03:07Obviously, that doesn't apply to anyone, so Access returns the zero results.
03:11Let's go back into Design View.
03:13If we change 'and' here to the word 'or', so now it reads 'manufacturing' or
03:19'quality assurance', I'll click to the end and press Enter.
03:23Now I'll run the datasheet, and we'll get the same results that we had when
03:27they were on multiple lines.
03:28So changing 'and' to 'or' is the easy fix to a common mistake.
03:32Now we get the results that we expected.
03:34There is one place where using the logical operator 'and' makes sense.
03:38Let's go back into Design View the last time, and I am going to add in our
03:42HireDate field from the Employees table to the query.
03:45Let's say that we are interested in only the Manufacturing or Quality Assurance
03:49people that were hired in 2012.
03:51We can go into the Criteria row here and type it out.
03:55I will say between and the first day of 2012, 1/1/2012, and the 12/31/2012.
04:06I'll make that field a little larger, so we can see the whole thing.
04:08And now, we can specify a range by using 'and' here because that makes sense in this context.
04:14Go ahead and run it.
04:14And we'll see just the 14 employees that are either in Manufacturing or the
04:19Quality Assurance departments that were hired in the year 2012.
04:23We did that by making use of multiple criteria on the same line in the Access
04:27Query Design View and mixing in a couple of 'and' and 'or' logical operators.
Collapse this transcript
Filtering with mathematical comparisons
00:00When it comes to filtering data, there is one additional class of operators that
00:04is specifically used with numerical data.
00:06They're called Comparison Operators and they are useful for all those
00:10situations where you want to specify records returned that are above or below a
00:13specific numerical value.
00:15Let's put those to use in our Employees query.
00:17I will go to Create>Query Design.
00:21I'll add the Employees table to our query, and close the Show Table window.
00:25And from the Employees table, we'll add the FirstName, LastName, and I'll scroll
00:30down to get salary and job rating.
00:34You're probably already familiar with the Comparison Operators even if you don't
00:37know them by that name.
00:38I am going to right-click on the Criteria field underneath Job Rating, and
00:43select this box called Zoom.
00:45This window here will just give me a larger area to type.
00:48We can change the font size;
00:50it might make it a little easier to see.
00:51I'll change it up to 16 and say OK.
00:55The Comparison Operators are the less than symbol, the greater than symbol, the
01:00less than or equal to symbol, the greater than or equal to symbol, equals, and
01:07is not equal to, there.
01:08Now I can go ahead and delete these out.
01:12Now if we wanted to see just our highest rated employees, we've seen already
01:16how we could type out something like this;
01:17"4" or "5" as our criteria.
01:22Well, we can do the same thing using Comparison Operator.
01:25I'll delete this again, and I'll simply say '>=4'.
01:28We will say OK to add that down into my criteria, down here.
01:36This is easy when we have discrete steps like our Job Ratings which only have
01:40five values to choose from, but what about salaries which can be any value?
01:44Well, we can do the same thing using our salary criteria, something like >70,000
01:49to get everyone that is at a pay level and above, without having to specify
01:52every dollar value possible and a really long chain of 'or' statements.
01:55Let's go ahead and run this query to see the results.
02:00You can see that we've got a total of 75 employees that are making above
02:03$70,000, and also have a job rating at 4 or 5.
02:08When filtering based off of numerical values, think about specifying values with
02:12the comparison operators;
02:13the less than, greater than, and equal to signs make specifying entire ranges of data quick and easy.
Collapse this transcript
Creating flexible queries with parameter requests
00:00Sometimes you'll want to create a query framework that answers many variations
00:04on the same question.
00:06Instead of hard-coding your queries to use the exact same criteria every time
00:10they run, you can instead ask the user when it's run for the criteria.
00:14This is called a parameter request, and they're another very useful tool to have
00:18when building your databases.
00:19We'll start by creating a simple query that looks at our customers.
00:22Under the Create Tab>Query Design, and add the Customers table.
00:27I'll close the Show Table window, and from that table, we'll choose FirstName,
00:31LastName, and I'll scroll down, and grab State.
00:36Now we've seen how to specify criteria that looks at a single state.
00:39For instance, down under the State in this Criteria row, I'll type WA to select
00:43all the customers that live in Washington State.
00:47If I were to save his query, every time it's run, it will always return
00:51Washington customers.
00:53Now imagine creating 49 other variations of this query;
00:56one for every state in the country.
00:58That will be kind of tedious, and not to mention how quickly, that would clutter
01:01up your navigation pane.
01:03We can instead change this into a parameter request
01:05that asks for the state we're interested in when it's run.
01:08So I am going to delete where I put in Washington here, and instead I am going
01:12to type in a request, and I'll put this in square-brackets;
01:15so an open square-bracket, Which state would you like?
01:18and a closing square-bracket.
01:20Again, we can make the state columns wider by clicking and dragging the field.
01:24The text that I put between the square-brackets will become a prompt in a
01:27textbox when we run the query.
01:29Let's run it to see.
01:30I'll switch it to Data Sheet View, and we get this Enter Parameter Value
01:34textbox, Which state would you like?
01:36Here I can type in the abbreviation TX for Texas, and press OK.
01:40The query record set displays all of the customers that live in the state of Texas.
01:45We can rerun this query by pressing this Refresh button or by switching
01:48back-and-forth between Design View and Datasheet View.
01:51I'll press Refresh Here.
01:53We get the Enter Parameter Value box again.
01:55This time, I'll type CA for California, and press OK, and there is all of our
02:00California customers.
02:02It's simple, flexible, and very fast.
02:05We can also combine parameter requests with some of the other query criteria
02:09tricks that we've seen earlier in the course.
02:10For instance, we can combine one with a wildcard character to filter last names to
02:14a specific character.
02:16Let's go back into Design View here, and I'll delete the State criteria.
02:20Underneath our LastName here, I'll write it out a parameter request that uses a
02:25wildcard character. All right. Like, open square-bracket, enter first character
02:32of LastName, closing square-bracket, I'll then type ampersand, which will simply
02:38join whatever I type in the Parameter Request box to this asterisk character
02:43that I wrap in quotation marks.
02:45Let me enlarge this field so we can see the whole thing.
02:48So it reads Like, open square-bracket, Enter First Character of last name,
02:53closing bracket, ampersand, quotation mark, asterisk, and the final quotation mark.
03:00Okay, let's go ahead and run this query.
03:02I will view its datasheet. We get the Parameter Request box: Enter First
03:06Character of LastName.
03:07Here I can type in A and press OK and now Access returns all of the customers
03:12whose last name starts with the letter A.
03:14If I press Refresh and type in a different character, this time, I'll type M, say OK.
03:20Now we get all the customers whose last name starts with M.
03:23Parameter Requests add another level of customization to your database processes
03:27and it can allow you to quickly build a query framework that can answer an
03:31infinite number of queries.
03:32Whatever we type into the Parameter Request box gets populated into the Criteria
03:36field and it allows us to create one query that answers lots of questions,
03:40rather than creating many queries, it only answer one question each.
Collapse this transcript
Building expressions
00:00In all of the queries that we've built so far, we focused on starting with the
00:04data that is in our tables, and then filtering it using a variety of techniques.
00:08Another very powerful ability of queries is to create new columns that are
00:12calculated from the existing data columns.
00:14The advantage of this is that we don't need to actually store this data in the database.
00:19We simply calculate it when we need it, and get rid of it when we don't. In our
00:23database, we have our employees' annual salary.
00:25If I open up the Employees table, we can see that over on the far-right side, here.
00:29Let's go ahead and close that table.
00:31We can create a query that will calculate the biweekly paycheck amount from that salary.
00:36We'll go to the Create Tab, and Query Design.
00:39I'll add the Employees table.
00:42I'll press Add and Close.
00:44Then from that, I'll choose the FirstName, LastName, and I'll scroll down, and
00:50double-click on Salary.
00:51In the fourth column is where we're going to enter in our calculation.
00:54I'm going to right-click on the fourth column, and go to Build to launch
00:58the Expression Builder.
00:59I can also get to the Expression Builder by clicking the Builder button up
01:02here on the Ribbon.
01:04Either way will take you to the same tool.
01:06I'll use the right-click menu and say Build here.
01:10And that brings up this Expression Builder.
01:12The Expression Builder is a tool that has a lot of depth, and it definitely
01:16rewards exploration.
01:17On the left side, we have an Expression Elements, which include groups for
01:20Functions, and database objects.
01:22We are going to open up the NoObstacles group here, and in the Tables group, and
01:28within the Tables group, we see a list of all of the tables in our database.
01:32I'll click on the Employees table.
01:34Now in the second pane, we get a listing of all of the fields from that table.
01:38I'll scroll down, and I'll double-click on Salary to add that up to the
01:41expression syntax up above.
01:43Now we just need to finish the formula.
01:45I'll say divide it by 26.
01:47There is 26 pay periods in a year.
01:49We'll go ahead, and say OK, and Access adds that expression into our
01:54calculated field here.
01:56It gives it a name too, Expr1, and that's not very descriptive.
02:00So I am going to highlight that and rename it Bi-Weekly.
02:05Make sure you keep the colon after that.
02:08Now we can go ahead and run this to see the results.
02:11Now there is a lot of decimals here, so it might not be wide enough.
02:15I'll drag this open to view the whole number and now we can see the Biweekly
02:19paycheck amount for each employee.
02:20Now we can clean up this data a little bit back in Design View.
02:24Go back to Design View, and I'll make sure that I've selected this fourth column here.
02:28Now just like when we created our columns in our tables, we had to define which
02:33data type we used, we can do the same thing here.
02:35Since we've calculated this, we can go up to the Property Sheet by opening the
02:39Properties here, and telling it the format here is Currency.
02:44That will clean up the numbers.
02:47Let's go ahead and close the Property Sheet, and rerun it to view.
02:50Now that's a lot cleaner.
02:52Let's go ahead and create another expression.
02:54I'll go back into Design View.
02:57And in the next column over, we'll create a new expression that calculates
03:01initials from our first and last names.
03:03I'll right-click once again, and go to Build, and this time I am going to go
03:08into our Functions group.
03:09Inside Functions, we'll find a listing of functions called Built-In Functions.
03:13And then in the Expression Categories here, in the second column, we'll scroll
03:16down until we get to our Text functions.
03:19Within the Text functions group, we'll find a function called Left, here.
03:25We can see when we click on it, the Left returns a specified number of
03:29characters from the left side of a string.
03:31I'll double-click on it to add it up into my Expression Builder.
03:34The Left function requires two arguments;
03:36a string and the length that we want.
03:39I'll click on the word String here.
03:41Now this first part is going to extract the first character from the first name.
03:47I can find the first name by going back into my NoObstacles element here into
03:52the tables, into my Employees table, and I'll double-click on FirstName.
03:57It adds the syntax up at the top.
03:59The Length, I'll click there, is going to be 1.
04:02So that will extract the first character from our first name.
04:06Now we need to do the same thing to get the first character from our LastName.
04:10I'll type an Ampersand because we're going to join these two together, and
04:14we'll repeat the process.
04:15Go back up to Functions>Built-In Functions, scroll down to Text, scroll down to
04:21Left and double-click.
04:23Then where it says string, I'll click there to select it, go into my database,
04:28the Tables, scrolling down into the Employees table.
04:32And finally, I'll double-click on the LastName.
04:36The Length again is going to be 1.
04:37We'll go ahead and say OK, and Access adds that expression down into
04:42our calculation here.
04:43Again, it gives it a new column name.
04:45I'll highlight the Expr1 and change this to Initials.
04:49Go ahead and say View to run the datasheet, and we'll see now we've got the
04:53Bi-Weekly amount in dollars, and we also have the employees' Initials here as a
04:58second calculated column.
05:00The Expression Builder is a complex tool that helps build proper syntax when
05:04using calculations and formulas.
05:06I definitely recommend spending some time with the Expression Builder to take a
05:09look at some of the nearly 200 built-in functions that come with Access.
05:14And if you'd like to get some additional help using the Expression Builder, take
05:17a look at my Access 2010 Queries in Depth ourse available here at lynda.com.
Collapse this transcript
Obtaining summary statistics
00:00Most queries return a record set, that temporary table of all the records that
00:04match your chosen criteria.
00:06Once you've gathered your records together, you can then tell Access to provide
00:10some summary statistics about the record that's gathered.
00:13This is called a Totals Query.
00:14Let's see how we can use one to gain some insight into the performance of
00:18NoObstacles across the various regions that we market to.
00:21I am going to start a new query in Design View by going to the Create Tab>Query
00:25Design and I am going to add a couple of tables.
00:29I am going to add the Orders table and the States table.
00:32Now we can see in the background that those two tables aren't directly
00:35related to each other.
00:36I'll need to add an additional couple of tables to provide a link.
00:40We are going to add-in the Products table, and the Customers table.
00:44We'll go ahead and close the Show Table window.
00:46Now we can see that we have an unbroken link from table to table to table.
00:50I'll rearrange them, so it's a little bit clearer what's going on here.
00:54Now we can see that we have a customer, the customers live in specific states,
00:58the customers place an order for products.
01:01Now from these tables, I am going to add-in a few fields.
01:04From the States table, we're going to double-click on RegionName, and from the
01:08Orders table, I want to choose ReceiptID and Quantity.
01:13Now if I run this query right now, we'll see that we just get a listing of all
01:17the receipts here, which region they came from, and how many products were
01:21ordered on that receipt.
01:22Let's switch back into Design View.
01:24I am going to change this record set now into a Totals Query by pressing the
01:28button at the top here in the Show/Hide group, Totals.
01:31When I do that, you will notice a new row shows up down on the grid below,
01:35Totals here, and everything is set to Group By.
01:38In this row, we'll choose the summary statistic type that we would like to
01:42apply to each column.
01:44We want to see each of our regions.
01:45So I am going to leave that as Group By.
01:48For ReceiptID, I'd like to see how many sales we have in each region.
01:51I'll change this to Count using the dropdown.
01:54For the Quantity, we'd like to get the total number of products sold.
01:58I am going to change this one to Sum.
02:00Now I can actually add some additional quantity fields to get additional statistics.
02:05I'll go back up to the Orders table, and I'll double-click on Quantity three more times.
02:10I am going to change their totals to Average, Min, and Max.
02:15Finally, I can include a calculated column, by typing in the formula here in this last field.
02:20I'll type [price]*[quantity].
02:28This will multiply whatever is found in the Price column by whatever is found in
02:34the Quantity column from our tables.
02:37From that, I can change its statistic to Sum.
02:40This will give me the grand total of all of the orders placed within the region.
02:44Let's go ahead and run this query to see the difference.
02:47We'll run it, and we'll see each of our region names.
02:50Within each region, we can see how many IDs or how many receipts have been
02:55collected within each region.
02:57I can see that the Northeast region only has 29 total receipts.
03:00The SumOfQuantity tells us how many products were ordered.
03:05The AvgOfQuantity, and I'll have to enlarge this to see it, tells me the average
03:09number of products per receipt.
03:11The MinOfQuantity tells me the lowest number of products on a receipt, in this
03:16case, the lowest number we had was 2.
03:19The MaxOfQuantity tells us the most number of products ordered on any one
03:22receipt in that region, in this case, 50.
03:25And finally, we can see the total value that each region has contributed to the company;
03:30$146,000 in the Northeast region.
03:33With the Totals query, I can quickly see that the Northeast region is
03:36underperforming with only 29 total sales.
03:39But I can also see that the average number of products per sale is right on
03:42track with our other regions.
03:44From a management perspective, this is a pretty valuable insight.
03:48Instead of focusing our attention on selling more products to each customer,
03:51we should focus our energies in the Northeast region on gaining more customers overall.
03:56Turning on the Totals row in Design View unlocks several ways that I can collect
04:00many records into a group such as our regions here, and then display the summary
04:04statistics across all of the records in each group.
Collapse this transcript
6. Working with Specialty Queries
Using update queries
00:00All of the queries that we've looked at so far were examples of Select Queries.
00:04These are queries that merely look through your data tables, and pull out
00:07the relevant records.
00:09There is a second class of query called Action Queries.
00:11These will go through your data tables, and actually make changes to the data within.
00:15When used properly, they can be extremely useful to help change large amounts
00:19of data very quickly.
00:20They can also quickly create huge headache if things go awry.
00:23So make sure you have a backup in place whenever you attempt to run an action query.
00:27The first one that I want to take a look at is called the Update Query.
00:30To begin, we'll start in the familiar Query Design View by going to the Create
00:35Tab, and starting a new query with the Design View here.
00:39Now let's suppose that NoObstacles decides to automatically enroll all of the
00:43full-time employees in the company's retirement benefit program.
00:47We can create an update query to add the benefit flag to employees based off of their status.
00:52I am going to add employees to the Query Grid, and then press the Close button
00:56to dismiss the Show Table window.
00:59From the Employees table, I am going to choose a few fields.
01:02I'll double-click on EmployeeID, FirstName, LastName.
01:04I'll scroll down and pick up Status, and a little further, scroll down, and
01:11get BenefitRetirement.
01:13We'll double-click on each one to add them to the grid below.
01:16Now I am going to add some criteria to my query.
01:19Underneath Status, I am going to type in 'full-time' in quotation marks.
01:22This will filter my query results to only the full-time employees.
01:28I can run the query at this point and see the results.
01:31I can see that I have 393 full-time employees, and I can see that some of them
01:35are already receiving our retirement benefits, but some are not.
01:39Let's go ahead and switch back into Design View.
01:40I am going to press the Update button here on the Ribbon to convert this query
01:46from a Select query into an Update query.
01:49When I do that, we get a new row down here in the Query Design grid.
01:52Underneath BenefitRetirement, in that Update To row, I am going to change this to Yes.
01:58When I tab out of that field, Access capitalizes the word Yes.
02:01And basically, this just means that whatever is in this field is going to get
02:05changed to a Check or Yes.
02:07Now with all of the action queries, running the query here and viewing the
02:12datasheet are two very different things.
02:15I'll click on the View button to view the fields that are about to change.
02:18These are all the checkboxes that will be affected by the Update To row.
02:22I'll go ahead and switch back into Design View.
02:25And now when I press Run here, Access will go ahead and convert those changes.
02:30Here, I'll get a warning saying 'You are about to update 393 row(s).' Once you
02:34click Yes, you can't undo this command.
02:37Remember, changes to data are saved automatically.
02:41If you are sure you want to make the changes, go ahead and press Yes, here.
02:44The changes have been made, and we can go back and view our datasheet again
02:48to see the results.
02:50If we want to see the results in context, we can also return to the
02:53Employees table here.
02:54I'll open up the Employees table, and I'll scroll across.
02:58And now, any of the full-time employees should have the BenefitRetirement field checked.
03:03The Update Query can make quick work of updating lots of records at once.
03:08The advantage to using a query to do this work over the Table tools' Find &
03:11Replace option, is that you can leverage everything we've explored in
03:15filtering and using query criteria to target or limit the updates to very specific records.
Collapse this transcript
Using make table queries
00:00The Make Table action query is useful if you would like to convert a query's
00:04temporary record set into a standalone table.
00:07This is perfect for exporting a snapshot of the data as it exists today.
00:12Remember, that queries by their nature update automatically to show the
00:16current state of the data.
00:17By exporting the results to a new table, you can essentially freeze their results.
00:22Right now, the NoObstacles employee table includes our 2012 salary and job ratings.
00:28Before the manufacturing department head can go through and update them for
00:312013, we would want to create an archive table so we can go back and see how
00:37things have changed from year to year.
00:39I am going to go up and create a new query in Design view.
00:42We're going to add the Employees table and close the Show Table window.
00:47Now we'll start populating our grid with some fields from the Employees table.
00:51I'll add the EmployeeID, FirstName, LastName, the Department and I'll scroll
00:57down and add Status, Salary and JobRating.
01:07Now we would like to add a criteria to our department.
01:09We're going to focus on just the Employees in the manufacturing department.
01:13Now I'm gong to write this out here using a wildcard character so that I can
01:17grab all of the manufacturing departments, including manufacturing and
01:20manufacturing administration.
01:22So I'll write the word like manufacturing*.
01:25When I press Enter, Access adds in the quotation marks for me and I can expand
01:31the field here to see the entire result there.
01:34Let's go ahead and view our datasheet to confirm the results.
01:37I'll click here and I can see that I've got a total of 158 total employees
01:43in the Manufacturing Department, including if I scroll down Manufacturing Administration.
01:49Now let's go back into Design view and convert this into a Make Table query.
01:52I'll switch to my View and I'll go up here in the Query Type group on the Design
01:58tab and I'll change this query from a Select query into a Make Table query.
02:03Access asks us to name the new table.
02:05I'm going to call it, Manufacturing Employees 2012.
02:10We're given the option to save this table in the Current Database or we can
02:14store it an external archive database if we prefer.
02:17I'm going to keep it in the Current Database.
02:19We'll go ahead and say, OK.
02:22Nothing really changes down here in the Query Grid.
02:24But if we run it, Access still tell us that we're about to paste a 158 rows into a new table.
02:30That's exactly what we want, so I'll go ahead and say, Yes, and the new table
02:33is created over here.
02:35If I open it up to take a look, you'll see it includes only the 158
02:38Manufacturing, and I'll open this us up again, and scrolling down
02:43Manufacturing Admin employees.
02:45The Make Table query is a great way to copy a large number of records into a permanent table.
02:50It sets up the table structure, defines the field headings and data types and
02:54populates all of the records in a single step.
Collapse this transcript
Using delete queries
00:00It probably goes without saying, what the Delete Query does.
00:04By using our knowledge of query criteria, we can set up a Delete query to
00:08selectively remove records from the database.
00:10This is a permanent and destructive edit that we're going to make.
00:13So again, make sure you have a solid backup of your database in place before proceeding.
00:18Let's suppose we've been tasked with removing the records for all canceled
00:22orders that were placed in 2011 and are now over a year old.
00:26If we open up the Orders table here we'll see the orders that were placed in
00:312011, and here and there we've got some orders that were canceled for one reason or another.
00:36To remove those from the database we'll use a Delete Query in several criteria.
00:40Like the other action queries the Delete query starts off as a regular Select
00:43query in Design view.
00:45I'll go to Create and Query Design.
00:48We're going to add the Orders table to our query and press Close.
00:52Now we'll add in a few fields.
00:54I'll add the ReceiptID, the Purchase Date and the Status.
01:01I don't need to add the other fields because they're not relevant to my criteria.
01:05But remember, way back at the beginning when I said that records represented in
01:08unbreakable unit all the way across the row?
01:11Even though every field won't be in the Delete query, if a record is deleted its
01:16information will be removed from every field.
01:19We're going to add in some criteria to our delete query here.
01:22For the date, I'm going to put in <=12/31/2011.
01:29I'll press Tab to move over to the criteria for the Status and here I'm going to
01:33type in canceled and press Enter to accept that change.
01:38Now I can safely run this query to see the four records that match.
01:42I'll change it to Datasheet view here and there are the records that are
01:45going to be deleted.
01:46I'll switch back into Design view, and at this point we'll convert it from a
01:51Select query to a Delete query using this button here in the Query Type group on the Design tab.
01:56Now it's a Delete query and when I press Run, I'll get the warning, that I'm
02:00about to delete 4 rows from the specified table.
02:03Once you click Yes, you can't undo the command to reverse the changes.
02:07Are you sure you want to delete the selected records?
02:10Yes, let's go ahead and delete them from the database.
02:12When you press Yes, those records are gone.
02:15We can confirm this by closing the query.
02:18I don't need to save any changes because it won't work again, there aren't
02:21anymore records to delete.
02:23And now if I take a look at my Orders table, I'll see these rows saying Deleted.
02:26If I press Refresh, those are gone from the database.
02:30Once you run a Delete Query, those records are immediately deleted.
02:33There is no Undo ability to get them back.
02:35So make sure that you've checked the results out thoroughly, when you're still in
02:38the Select query mode, before converting the query to a Delete query.
02:42If you make a mistake with a Delete query your only recourse is to return to
02:46that all-important backup.
Collapse this transcript
Using append queries
00:00When you want to permanently join the contents of two tables together, you can
00:04use an Append query to make quick work of a task.
00:07NoObstacles recently added to the available colors in their line of bath
00:10towels and we've received a table here, NewProducts from the manufacture
00:14detailing the new specifications.
00:16We can see the bath towels here and the new color options that are available.
00:20Rather than manually typing all of this into our existing Products table, we can
00:24create an Append query to do the work for us.
00:26I'm going to close the NewProducts table and start a new query in Design view.
00:31On the Create tab, press Query Design.
00:33Let's add the NewProducts tables to our query and I'll close the Show Table window.
00:40And now, we're going to add the fields from the table down into our Query Grid.
00:44I'm going to grab all of the fields except for the ProductID, the primary key.
00:48So I'll add Product, Department, Category, Size, scrolling down we'll grab
00:54Color, Price, Description and finally the Rating.
00:59Since our Products table is set to create an auto number ID, each of these new
01:03products will automatically be assigned a new ID when they get appended to the
01:06full product listing, in order to ensure that there are no conflicts.
01:11Now let's go ahead and change this query to an Append query here on the ribbon.
01:16Access will ask us which table we want to append these records to.
01:19I can use the dropdown list to choose our Products table here.
01:25We also have the option to append to another table in a different database.
01:28We'll go ahead and say, OK and Access adds this Append To row down here.
01:34These are the fields from the existing Products table that we're going to append to.
01:38Now because the field names in both tables are the same, Access has already
01:42correctly matched them all up.
01:44If your fields have different names among the two tables, then you may need to
01:47manually tell Access which data goes into which field.
01:51Once we've verified that all of the data will go into the right location, I'll
01:55press the Run button on the ribbon.
01:58Access tells us that we're about to append 21 rows, once you click Yes you can't undo it.
02:03Go ahead and press Yes to append those records.
02:05Now I can close this query, I don't need to save it because they are already
02:09added and I don't want to add a duplicate copy.
02:12Go ahead and say, No we don't want to save those changes.
02:15Now we take a look at our Products table here and we'll see that we have a total
02:19of 321 products now, instead of the 300 we had previously.
02:22And if I scroll to the very bottom, you'll see the new bath towels and the new
02:28color options added to the bottom.
02:30Anytime you need to add lots of records to your database and they're coming from
02:33a pre-tabulated source such as an Excel file or another spreadsheet, take a look
02:38at using an Append query before you try and manually retyping everything to get
02:42it into your database.
02:44Whether you have 10 records or 10,000 records you'll be finished with
02:47the task in no time.
Collapse this transcript
Getting a different look with crosstab queries
00:00Queries generally follow the rows and columns or records and fields model for their layout.
00:05There's also a slightly modified layout option called the Crosstab query, that
00:09gives us headers along the top and side and aggregate or summary data appears in the middle.
00:13Let's put one together using our phone list so you can see how this works.
00:18Now right now our EmployeePhone lists are stored in a second related table.
00:22This provides flexibility in adding multiple numbers for each employee where
00:26most employees will have at least one office phone, but some might have
00:30additional lines for their cell phone, their fax number or their home phone or
00:33an emergency contact number.
00:35I would like to first put together a Select query that gathers all of these
00:39numbers and then convert that query into a Crosstab format, so you can see the
00:43improvement in legibility.
00:44I'll go ahead and close the EmployeePhone table and we'll start a new query in Design view.
00:49I'll add the Employees table and the EmployeePhone table and close the Show Table window.
00:57Now I'll pull in a few fields.
00:58From the Employees table I'll double-click on FirstName and LastName and from
01:02the EmployeePhone phone table I'll grab the Number and the Type.
01:05Let's go ahead and view the datasheet to see the records we've collected.
01:09You'll see multiple lines for each employee which is not quite ideal.
01:13Let's go back into Design view and clean it up.
01:15I'm going to change the Query Type from Select query over here to Crosstab query.
01:19When I do that I get two additional rows down here in the grid, Crosstab and Total.
01:24In the Crosstab row we're going to define what fields go where in the grid.
01:29Our first and last names are going to be Row Headings.
01:33I'll click the dropdown and choose the Row Heading.
01:36The Type will become our Column Heading and the number is what's going to appear
01:40in the middle, we're going to choose Value.
01:43Now also for the number we need to choose how we want to show those values.
01:46We're going to change this Totals row to First.
01:49The Total is how we want to aggregate or summarize the data in this area.
01:53Most of these options will make sense for numerical data such as sum or average
01:57but wouldn't make any sense for phone numbers.
01:59We'll choose First here, so that we're not applying any sort of mathematical
02:04transformations to the data.
02:06Now finally I want to make this a usable directory so I'm going to apply a Sort
02:09on LastName to alphabetize it ascending.
02:12Now let's go ahead and view the datasheet to see the difference.
02:16It's exactly the same data as before just displayed in a more compact way.
02:21Each employee now only has one row but we still see all of their phone numbers
02:25with a type listed across the top. Further,
02:29this layout makes it very easy to see what employees are missing
02:32crucial information.
02:33Maybe it's time to put some pressure on people to give us those
02:36emergency contact numbers.
02:38Crosstab queries can provide a different organization to your data, sometimes
02:42making it easier to read, make comparisons or spot trends.
02:46The aggregate values that appear at the intersection of the row and column can
02:50also be set to display account of how many records are in that group or their
02:54sum total, average, lowest, or highest values.
Collapse this transcript
Creating a union query in SQL view
00:00The Query Design view is exceptionally powerful and it allows you to create a
00:04query for nearly any scenario that you can imagine.
00:07However, it really is just a front end to something even more powerful that's
00:10happening in the background.
00:11When you create a query in Design View, Access is translating those instructions
00:16into code called Structured Query Language or SQL.
00:20You can see the code for the queries that you created by switching into the
00:23third view mode SQL.
00:25I'll double-click on the EmployeePhoneNumbers query to run and then go up to
00:29View menu and click on the bottom half and change my View to SQL View.
00:34Now I'm not going to be able to get into writing queries in SQL.
00:37There are other courses in the lynda.com library that cover this in-depth topic.
00:41But I thought it would be helpful for you to get just a taste of what this looks like.
00:46The snippets of code that you see here is literally everywhere in Access and the
00:50more familiarity you have with its structure and syntax conventions, the easier
00:54it will be for you to create amazing database applications.
00:57But for now, I want to walk you through the creation of one query type that you
01:01actually cannot create using the Design View.
01:04The Union query is useful when you want to temporarily join two tables together.
01:09Unlike the Append query which permanently copies data from one table and saves
01:13it into another, the Union query keeps the original data tables untouched, but
01:18returns a temporary record set that functions exactly as if you had joined them together.
01:23So let's go ahead and close this EmployeePhoneNumbers query.
01:25I'm going to start a new query in Design view by going to Create>Query Design.
01:31Now let's suppose that NoObstacles has products split up by category to coincide
01:36with the structure of their management team, with separate tables for the
01:39Furniture and Textiles products.
01:43The Furniture Manager typically doesn't much care about the textiles and vice versa.
01:47However, occasionally we do need to take a look at the entire product line.
01:51We can keep these tables separate for day-to-day management, but create a Union
01:55query for those rare times when we want to look at the entire group of products together.
02:00Here in my Query Design view I'm going to add the Products-Furniture table and
02:05press Add and close Show Table.
02:08A shortcut to add all of the fields to the Query Grid is to double-click on the
02:12Asterisk (*) character at the top of the field list.
02:14I could run my query in Datasheet view, to confirm that I am indeed grabbing all
02:17of the fields from that table.
02:20Now I'll switch my View into SQL and we'll see the syntax that generated that
02:24query, it says SELECT[Products-Furniture].* FROM[Products-Furniture] table.
02:31There is a semicolon
02:32at the end here and I'm going to click before that and press Enter a few times
02:36to move that semicolon down on the page.
02:38Now we just need to use this as a model to type out the rest of our Union query.
02:43I am going to go ahead and type the word UNION, press Enter a few more times and
02:48I am going to follow this with a reference to the Products-Textiles table.
02:51Now I'm just going to copy the syntax that I see up above.
02:54So I'll write SELECT [Products.Textiles].*
02:59I'll press Enter to go to the next line, FROM [Products-Textiles] and there we
03:12go, that's the extent of my Union query.
03:14Now I can run this query to see the results and I can scroll through the list to
03:18see that indeed we have products in the Category Textiles and if I scroll down
03:23we'll get products in the Category Furniture all merged together.
03:27Let's go ahead and save this query here.
03:29I'll go up and press the Save icon on the Quick Access toolbar and I'll save
03:32this as All Products Union Query and press OK.
03:38You'll notice that it shows up in the Navigation pane with a different icon
03:41indicating that this is a Union query.
03:43Now whenever I want to build a report or form or query off of just a single
03:47department, I'll use these tables as a source.
03:50If I want to build out form or report or query based off of the complete listing
03:54of all products, I'll use this Union query as the source.
03:57The Union Query is a great example of the type of thing that's possible with
04:01just a smidge of SQL knowledge.
04:03Gaining experience with Structured Query Language is something that I
04:06would highly recommend when it comes time to take your Access skills to the next level.
04:10However, with the flexibility and control you get with a Standard Query design
04:13environment, it's really not required knowledge for all but the most specialized
04:17queries that you might want to construct.
Collapse this transcript
7. Creating Forms
Understanding the role of forms
00:00The next Access object that we're going to start working with is Forms.
00:04Forms will create the main user interface for your database and allow you to
00:07set up navigation systems and group tasks in ways that make sense for your organization.
00:12I am going to open up some of the forms that we will be creating over the next two chapters.
00:17First, let's take a look at this Training Department Employees form.
00:20I'll scroll down here and double-click to open it.
00:23Forms provide a blank canvas for you to populate with lots of objects in order
00:26to manipulate the data and functionality of the database.
00:29You'll be able to add references to table fields and records such as these text
00:33boxes up here that I connected to the name fields for our employees.
00:37Each field on the form acts as a window into a single cell on the source table
00:42and any edits that you make on the form get saved right back into the table.
00:46You can add additional controls to your data.
00:48On this form we can navigate through our employees just like we can with the
00:51table using the navigation buttons at the bottom.
00:55Or on this form I've got a search box in the upper right-hand corner.
00:59I can use the dropdown list to quickly jump to a specific person.
01:03I can even just start typing and press Enter to jump to specific person as well.
01:08Down here we've built an option group to improve the way that we interact with
01:12the job rating field.
01:13On the table this is just a numerical score of 1 through 5, but on the form
01:18we can add descriptive display text that will translate the number value in the background.
01:23And forms will allow you to add buttons that are attached to macros or visual
01:27basic routines such as these buttons here are on the right.
01:30This one will add a new employee to the database and this one here will
01:33print their record.
01:34I'll go ahead and press Cancel.
01:36Forms will allow you to create a unique experience for the users of your database
01:40by adding images and using font and color schemes that are pleasing to work with
01:44and that support your organization's brand.
01:47Primarily, Forms will be used to interact with your data.
01:50They typically display one record at a time in a highly customizable way so that
01:53you can see the entire picture of how the related fields come together.
01:57But you can also create forms to display many records at a time.
02:00Such as this Employee Phone List form.
02:03This one is a scrolling list of phone numbers that has a stylized header here at the top.
02:08Finally, Forms can be used to organize buttons into logical groupings of related tasks.
02:12For instance with a Navigation Form, like this one here, you can use buttons to
02:18move from objects to object.
02:22This completely bypasses the long list in the Navigation pane, which I can safely
02:27close and still be able to get around through my database.
02:30In fact, a well-crafted database often bypasses the navigation pane altogether
02:34as it means for moving from task to task.
02:36This allows you to work in a way that makes sense for your particular workflow
02:39in sequence and as an added benefit, or maybe even the most important benefit,
02:44this also keeps people focused on the areas of the database that they should be working with.
02:48It can help keep them out of the areas that should stay behind the scenes.
Collapse this transcript
Generating forms from tables
00:00You can have a basic data entry form up and running in as little as two clicks.
00:05First, select the table you'll like to create a form for in the navigation pane.
00:09I'll choose the Employees table.
00:11Then on the Create tab of the ribbon press the Form button here.
00:16Access sets up the form.
00:17This form has cells that correspond to a single employee's record in our table.
00:22We can view this information or edit it to make changes back in the table
00:26and just like viewing a table we have the same record selectors across the bottom here.
00:31In addition to the text boxes that hold information from the Employees
00:34table Access recognizes the relationship between Employees and the
00:38EmployeePhones table.
00:39If I just go down to the bottom we can see that down here.
00:43Access has created a sub-datasheet that displays all of the related records for each employee.
00:48Notice that that the sub-datasheet has its own set of record selectors here.
00:52We can also easily add additional phone numbers in this field.
00:56This illustrates one of the reasons why forms are used for data entry over
01:00entering data directly into tables.
01:01We can use forms to enter information into multiple tables simultaneously.
01:05Plus you don't need to manually manage the relationship between, in our case,
01:09Employees and their employee phone numbers.
01:12Because the form is currently displaying a single employee, Access knows that
01:16any phone numbers that we add belong to that employee and the foreign keys will
01:20get added automatically.
01:22Let's add a new phone number and then verify that it places it correctly it the tables.
01:26I'm going to jump to record number 10 for our Employees by clicking in the box
01:31and typing in 10 and pressing Enter.
01:34Access jumps to the record number 10, which is for our employee named Marc Navarro.
01:38Let's scroll down and add a new phone number for Marc.
01:42Here down on the second section of the sub-datasheet I'll press this new
01:46Record button here.
01:49Access adds a new phone number line for Marc and we can start typing in the value.
01:52Now remember that first field is a primary key for the phone numbers.
01:56We can't edit that number.
01:58So I'll press the Tab key to move to the next field and we'll enter in his
02:02phone number 6501230000.
02:07We'll go to Type and this is his home number.
02:11I'll press Enter to accept those changes.
02:13You'll notice that it got a new ID number here 1803.
02:17Now we can save and close this form.
02:20I'll close it up here, Access will prompt me to save the changes to the
02:25Employees form and I'll say Yes.
02:26I'll go ahead and accept that name and say, OK, and we'll notice a new forms
02:30group down here in the navigation pane with our Employees form.
02:34Now we can go ahead and open up the EmployeePhone number table to verify that
02:37the new number got entered correctly.
02:39I'll double-click on EmployeePhone and I'll use the Last Record button down here
02:43in the bottom to jump to the very end of the table and we can see that indeed we
02:48have that new phone number linked to EmployeeID number 10,
02:50that's Marc's employee ID number, and there's the number and the type that we entered.
02:56Having Access create a basic form for us probably couldn't get any easier.
03:00Select the table you want and press the Form button.
03:03However, there's a lot of additional functionality and customization that we can
03:06build into our forms using the Form Wizard in Design views.
Collapse this transcript
Adjusting form elements in Layout view
00:00The one-click form got us started by placing text boxes for all of our table
00:04fields onto the form.
00:06We can further refine the organization of the Form elements by using the Layout view.
00:10I'm going to open up the Employees form that we started in last movie by
00:13double-clicking on it in the navigation pane.
00:15We can change our view here to layout by clicking on the View button.
00:19Now we're in Layout view.
00:22Layout view allows us to rearrange and add elements, but it keeps everything
00:26organized on a standardized grid layout.
00:29Right now the form is organized into a single column.
00:31We can rearrange this layout by adding additional placeholder rows and
00:35columns to our Layout grid.
00:36On the Arrange tab of the ribbon go ahead and press the Insert Right button
00:40twice to add two additional columns over here on the right side.
00:44Now we can drag and drop these form elements into these placeholders in the grid.
00:48For instance, I'm going to take this LastName field where it says Tate.
00:52I'm going to drag-and-drop it over here to the right of Zachary, the FirstName.
00:57I can resize elements by clicking on them and dragging on their edges.
01:01Notice that when I do, it resizes everything in that column.
01:05I can resize the height by dragging on the bottom and again it resizes
01:08everything in that entire row.
01:10The Layout view grid keeps everything organized.
01:14Now I can delete labels that we don't need such as this LastName label, by
01:17clicking on it and pressing the Delete key.
01:20If we want to edit a label, I'll double-click on it.
01:22For instance I'll double-click on this First Name one and just change it to read
01:26Name and press Enter.
01:28Now we can continue to rearrange our form elements into a more logical grouping.
01:33I'm going to move Department over here to the right and I'll grab the label for
01:36Department and move that as well.
01:38I'm going to move the Status up and the Status label up.
01:43If I want to grab multiple pieces at once, I can click on one and then
01:47Shift+Click on the other.
01:48Let's move HireDate over to the right of Status, here.
01:52Our Benefit Information, let's move it over to the right as well.
01:55I'll click on BenefitDental and then Shift+Click on this last checkbox.
01:59That will grab all six elements at once.
02:01We can drag and drop them in to position.
02:04Let's go ahead and scroll down.
02:06Salary and JobRating we can move those up.
02:09I'll click on Salary, Shift+Click on the 5 and drag those up and drop them into position.
02:15Let's get rid of the few rows that we don't need anymore.
02:17I'll click on this field and Shift+Click on the fourth one and press Delete and
02:22the entire row disappears.
02:24Now let's go ahead and give more room to our sub-datasheet here the bottom.
02:28I'll click on the sub-datasheet, Shift+Click on the other two fields to
02:32the right of it, and I'm going to press this Merge button up here on the ribbon.
02:36That will merge those three fields together giving our sub datasheet more room.
02:40Now we can rearrange the fields inside of that.
02:42I'm going to drag this ID open a little bit more and give a little more
02:45breathing room to our Number and Type.
02:48Let's go ahead and scroll up to the top.
02:50I can continue refining this a little bit more.
02:52I am going to leave this row here blank, but I'll use it as a spacer row.
02:57I'll go ahead and click on Taft here, the building row and I'll shrink that down.
03:01The same thing with the rows below it.
03:02I'll grab each one and make them a little bit narrower.
03:05That way we can fit more information on our screen.
03:12If we want to reduce the amount of spacing between our elements, I can select
03:15everything by clicking on this box here and then going up to Control Padding and
03:19choosing either None or the Narrow option. I'll choose Narrow.
03:22You can see that everything collapsed together a little bit more.
03:26Now that our form is a little bit more organized, we can view the results of our
03:30edits by changing back to Form View, by going to the Home tab and changing our
03:33View toggle button here.
03:34That will change us into Form View and we can cycle through the records to see
03:37how it works with multiple employees.
03:43If you need to make any changes, for instance, I'm noticing that this Department
03:46field isn't quite wide enough for my entire departments.
03:49I'll press the View button to toggle back and I can make those changes.
03:53Once I'm happy with the layout I'll go ahead and press the Save button to save
03:57those changes to the form.
03:59The Layout view grid makes it very easy to move your fields around quickly while
04:03keeping everything perfectly aligned and looking neat and clean.
Collapse this transcript
Using the Form Wizard
00:00The Form Wizard will walk us through some additional options we have when
00:03creating a form, giving us more flexibility in how the form is organized in a
00:07simple, one-click method.
00:09Let's create another form, this time for our employee directory.
00:13I'll choose the CREATE tab and from there I'll choose Form Wizard.
00:18We start with a screen that might look familiar to you.
00:21We saw the same thing when we worked with the Query Wizard.
00:24Essentially, we're going to use a query in the background to assemble the data
00:28for our form, so let's choose a couple of fields here.
00:30I'm going to choose from the Employees table, the FirstName, the LastName and
00:35we'll move those over, I'll also add the Building and Department fields.
00:39I'll then go back up here and change from my Employees table to my
00:44EmployeesPhone table, here.
00:46From there I'll choose Number and Type.
00:50The next step of the wizard gives us the option of including the related data as
00:53a subform or as a linked form.
00:57The subform option is what the one-click method created for us in the previous
01:01movie, so let's see what the linked form option look like.
01:04I'll go ahead and choose that radio button.
01:06We'll go ahead and say Next, we'll give our form some descriptive names.
01:10I'll call the first one Employee Offices and the second one Phone Numbers.
01:16Then we have the choice to either open the main form to view or enter
01:19information or Modify the design, I'm going to choose to open them to view the information.
01:24Press Finish and two new forms get added into our forms group down here in
01:28the Navigation Pane.
01:30Now we are seeing the Employee Offices form.
01:32Not all of the fields from the Employees table are present, because we only
01:35chose a select few to include here in our form, just the ones that are important
01:40for this particular task.
01:42There is a button up top that links to the Employee Phone Numbers in a separate form.
01:46However, there is a little bug here in Access in that this title appears above
01:50the button and makes it un-clickable.
01:51So we'll need to move that out of the way really quick and we can do that in Layout View.
01:56I'll change my View to Layout View, now I can click on this title here and drag
02:00it over here to the right.
02:02Then I'll grab the button, drag that all the way to the right side and then I'll
02:06move the label back to the beginning.
02:08Now let's switch back to our Form view.
02:10Now we can click on this button here, we're on the record for Zachary Tate, I'll
02:14press the Phone Numbers button and we can see all the Phone Numbers for Zachary.
02:18So using the Form Wizard we have more control over exactly what fields and
02:22related tables get displayed on the Form.
02:24Since this form is going to be used as a directory, there really isn't a reason
02:28to include salary and benefit information here, that would just add clutter.
02:32Keeping the form's content specific to the designated tasks makes for
02:36a much cleaner user experience.
Collapse this transcript
8. Designing Forms
Creating forms in Design view
00:00Creating Forms in Design View requires diving into a new design environment that
00:04looks different than what we've seen previously.
00:06I would like to take a few minutes to just have a look around before we start to
00:10create a new form in this view.
00:12I'm going to start by going to the CREATE tab and in the Forms group,
00:15choose Form Design.
00:17This will jump us into a new Design View for a new form.
00:20On the Ribbon we've got three new contextual tabs, the first is the DESIGN tab.
00:25This tab has options for changing our View here on the left, adjusting our Font
00:29and Color Themes, a large group of Control objects that we can add to our form,
00:34settings for our form's Header and Footer and some form design tools that we'll
00:39be making use of shortly.
00:41The next tab is the ARRANGE tab.
00:44Most of these tools deal with the Layout View, but over here on the right you'll
00:47find Sizing & Ordering.
00:49These tools will help us precisely align our objects within the grid.
00:53The next tab over is the FORMAT tab.
00:55The FORMAT has sections for selecting objects, adjusting our font, color and
01:00size, adjusting our number formatting, adding a Background Image or changing
01:05the Alternate Row Color of our records and some Control Formatting options, such
01:10as Quick Styles, changing their shape or adjusting their fill, outline or special effects.
01:16The rest of the form is currently just a big empty area for us to place our objects.
01:20It has a dot and grid pattern in the background to help us align things together.
01:24We can click and drag on the edges if we need some additional space to work.
01:28I can scroll down as well and grab the bottom and bring it up so I can see the
01:32bottom of my form, and I'll scroll back up.
01:35Moving objects around in Design View is slightly different than what you
01:38might be used to if you've ever worked with a layout program such as
01:40PowerPoint or Publisher.
01:42I'm going to go to the Controls group on the DESIGN tab of the Ribbon and
01:46grab this tool here with these lower case ab and a rectangle around it, this is a text box.
01:52The text box controls will typically be linked to a data source such as a
01:55field from a table.
01:57It will be where we will type when we want to edit a record.
02:00Clicking the object essentially picks it up.
02:03I like to think of these Controls groups as a toolbox.
02:05I've picked up the tool and my cursor changes to reflect the objects
02:09I'm currently holding.
02:10I'll click once in the blank form area to drop the object, now you'll see that
02:14the cursor returns to the standard arrow.
02:17When I added a text box I actually get a text box here and a label.
02:21The text box is the white one on the right.
02:23This is where our data will appear.
02:25The piece on the left, this is a label.
02:27Labels are static text that are informative in nature.
02:30They stay the same when you cycle from record to record.
02:34Now I can move the objects around by clicking on the orange highlighted edge.
02:37You click here and drag, you can see that they both come together.
02:41In order to move the objects independently, you'll need to use the large handle
02:45in the upper left-hand corner.
02:47I'll click it here on the label and drag it on top of the text box.
02:51Now if I try moving the text box, you'll see that they maintain this new arrangement.
02:55If you like to resize your objects, just click on the handles that are on the
02:59other edges of the bounding boxes.
03:00For instance I'll make this text box wider.
03:02I can click on the label and make the label wider as well.
03:06At any point we can switch in to Form View using the View button up here at the top.
03:11I'll press that and I'll go to my Working View.
03:13Notice if you wanted to go back into Design view you can't use the toggle
03:16button here at the top.
03:18But if I use the lower half of the View button, this will give me the list where
03:22I can switch in Design View.
03:23Of course you can always also use these icons down here in the bottom right to
03:27switch into Design View here.
03:29I'll switch back to Form View.
03:31Notice that in Form View we also no longer see the adjustment bounding boxes or
03:36that dot grid that appeared in the background.
03:38Working with the Design View of Forms takes a little bit of practice, because it
03:42may look a little different from many of your other experiences.
03:44But once you get used to some of its quirks, you'll be assembling custom forms in no time.
Collapse this transcript
Exploring the form property sheet
00:00Everything in Access has properties.
00:02Way back when we created our table fields, we saw that every field had
00:06properties like field length, caption, indexed or required.
00:10Forms and the objects that we'll place on to our forms all have properties as well.
00:15In Forms however, there are so many properties that we can modify and explore,
00:19that they are organized into a tab listing called the Property Sheet.
00:22I'm going to create a new form in Design View by going to the CREATE tab and
00:26pressing Form Design in the Forms group.
00:28Then on the far right of my Design tab, I'm going to turn on the Property Sheet here.
00:34I can resize the Property Sheet by clicking on the edge and dragging it open, if
00:38I'd like more space.
00:39The Property Sheet houses everything that you can possibly change for every
00:43object on your form.
00:44Right now, we're looking at the properties for the entire form.
00:48It says so in this dropdown list here.
00:50I can use the dropdown to select other objects or areas of my form.
00:54Currently, the only two objects I have are the form itself and the Detail section
00:58of the form, which is this middle area here.
01:01As we add objects to our form, this list will grow.
01:05Below that you'll see that the properties are split into five tabs.
01:09The Format tab has all of our formatting options, for instance our caption.
01:13That's what will appear at the tab on the top here.
01:16We've got the Default View which is how we are going to view our form;
01:20we've got properties for things like pictures, the width.
01:22We have got color and size and font options, all of that appears here in the Format tab.
01:28If you want to see the additional options you can scroll down through this list
01:31and you can see it's pretty long.
01:34The next tab is Data.
01:36The Data tab is how this form connects to its data source, where the records are
01:39coming from and where are they going to.
01:42We can also set properties for filtering or how to handle additions or deletions.
01:48The Events tab has all of the ways that we can trigger macros or Visual
01:52Basic routines and you can see that there's a lot of ways that we can
01:55trigger these events.
01:56We can trigger an event when the font loads for instance, or when you click on
02:00something, or when you double-click on something, or when the mouse clicks down
02:03and another one when the mouse lifts up.
02:06All of these available options we can link to macros using the dropdown list
02:09here to choose things from our database.
02:12The Other tab has miscellaneous items, such as whether this is a Pop Up form or a Modal form.
02:18A Pop Up form will float on top of other windows.
02:21A Modal form will force you to interact with it before you can do anything
02:25else in the database.
02:27And finally, the All tab is a master list of all of the properties from the first four tabs.
02:32So if you don't remember which tab a specific property was in, you can come to
02:36the All tab and find it in this one long list.
02:41When we're done with the Property Sheet, we can either close it with the X button
02:44here or toggle it off with this button here on the Ribbon.
02:48Some of the common properties that you'll want to change, such as font style or
02:52color, are also available through the Ribbon tabs up here at the top, for
02:55instance in this formatting group we have Font options here.
02:58However, the Property Sheet lists all of the available options regardless of if
03:03they are common, useful or obscure.
03:05It's definitely a long list, but getting familiar with its content can help you
03:09identify things that you'll want to modify in your forms.
Collapse this transcript
Setting data sources
00:00In order to create a form from scratch, the first thing we need to do is connect
00:04it to a data source.
00:05A form can get its data from either a table or a query, and if you choose a
00:10query you can either use a pre-made query that is saved over here in the
00:13Navigation pane, or create an embedded query directly inside of the form.
00:18Let's begin to create a form that we will refine over the next few movies.
00:22Here is the scenario: the head of the NoObstacles training department needs a form to manage her
00:27team's benefits and salary information.
00:30Let's create a form that is tailored to her specific needs.
00:33First, we'll create a query to gather the appropriate records.
00:37We can do that by going to the CREATE tab and then choose Query Design.
00:41I'm going to add in the Employees table and the EmployeePhone table.
00:46I'll readjust these so I can see all of the fields within each table, and now
00:50I'll start choosing my fields.
00:51I'm going to choose the FirstName and LastName, Building, Department and Status.
00:57We're not going to need to edit the HireDate, but we do want the Dental, Medical
01:02and Retirement benefits as well as Salary and JobRating.
01:07Finally, from the EmployeePhone table we want the phone Number and the Type.
01:12Now I'm going to scroll over here. Everything went off the screen so I'm going
01:15to make sure that I got everything including the phone Number and Type and
01:17those are all added, so that's good.
01:20Now I'll scroll back here, I'm going to add in a few criteria here to filter my list.
01:24I'm only interested in the Employees in the Training Department, so underneath
01:29Criteria I'm going to type in training.
01:31Also, I'm only interested in the phone numbers that are the office numbers.
01:35I don't need the home or cell number.
01:37So underneath Type in the Criteria row I'm going to type in office.
01:44I also don't need to see that this is the office number.
01:47Because it's on the form, I'll know it's the office number.
01:49I can use this show check box and turn it off which will still allow me to filter
01:53this record, but not display it in my results.
01:56Finally, because I want this to be a sorted list, I'm going to go all the way
02:01to the beginning and on the LastName I'm going to apply a sort here, turn that to Ascending.
02:07We can view the datasheet results by switching to Datasheet View and we'll see
02:11that we have 17 employees in the Training Department.
02:14It's sorted by LastName and if I scroll over to the right, we've got the phone Number information here.
02:22Okay, this is going to be the record source for our form, let's go ahead and save this query.
02:27I'll go up to the Quick Access toolbar and press the Save icon and I'm going
02:31to name this Employees-TrainingDepartment, go ahead and say OK and I'll close the query.
02:39Now we can start to create the form, I'll go to the CREATE tab and in the Forms
02:43group choose Form Design.
02:45I'll open up the Property Sheet for our form and go to the DATA tab.
02:51In the DATA tab we'll find a property called Record Source, this is where the
02:54data is going to be coming from.
02:56We can use the dropdown list here to see a listing of all of the tables and
03:00queries that are in our database.
03:01I'll find the Employees-TrainingDepartment query that we just built.
03:07Go ahead and select it and then close the Property Sheet.
03:11Now that it's connected, we can start adding our fields.
03:13I'll turn on the Add Existing Fields panel by clicking on the toggle and then
03:17we'll see all of the fields that are being prepared by the query.
03:21I'll click on the FirstName and then Shift-click on Number and now I can just
03:24drag and drop everything at once into the Detail section.
03:28Now that I'm done with existing fields I can close that panel.
03:31Now we can start rearranging these around on our Form into logical groupings.
03:36I'm going to take the LastName for instance and using the handle in the
03:39upper left-hand corner, I'm going to drag it and move it up here right beside FirstName.
03:43I'm going to take Building and Department and put them over here on the far right.
03:48I can highlight both of these at once and drag all of these together.
03:52I'm going to take all of the Benefit information, these check boxes here, I'll
03:58highlight over those and all at once I'll drag these over here to the right side as well.
04:04I'll move Salary up above Status. I'll move JobRating down below Status and
04:11I'll take the phone number field and drag it and put it right below the first and last name.
04:17I'm going to open this up a little bit to make it a little bit wider, and now I
04:21can delete some of these labels that are redundant.
04:23It's going to be pretty obvious that this is their first and last name and phone
04:27number so I don't need any of these labels.
04:30I'll click on the FirstName label and press Delete on my keyboard and I'll do
04:32the same for the other three.
04:34At any point in time we can switch into Form View using the toggle button up here.
04:38Now we see what our form looks like with data populated.
04:42We could use the Record selectors at the bottom to cycle through the
04:4517 employees in the Training Department.
04:48If I want to go make additional changes, I have to use the dropdown menu on the
04:52View button to switch into Design View.
04:54The toggle merely goes between Layout View and Form View.
04:58So forms that are going to be displaying data will need to get connected to a data
05:02source of some variety.
05:04This form is serving a very specific task and so we need it to gather a unique
05:09subset of records using a query.
05:11Once you have the query established, it's merely a matter of connecting the
05:14form to the query using the Record Source property and then adding the fields over to your form.
05:20At this point this a good place to save our form.
05:22I'll go up to the Quick Access toolbar, press the Save icon, and give it a name,
05:27Training Department Employees. Go ahead and say OK.
05:33Now our form is saved, if I scroll down in my Navigation pane, I can see it down
05:37here at the bottom of the list.
Collapse this transcript
Adding components with form controls
00:00Forms can have a variety of additional objects added to them in order to help
00:04customize their appearance and functionality.
00:07Collectively, these additional objects are called form controls and you can find
00:12them in the form Design View.
00:13Let's continue refining our Training Department Employees form.
00:17I'll go down and find it in the Navigation pane and I'll right-click on it and
00:21open a straight Design View.
00:23On the DESIGN tab up here, we have the Controls group with all of the things
00:27that we can add into our form.
00:29This is actually a scrolling list, there's all of these controls here, but we
00:33can also scroll down and see a whole another row of controls here.
00:36If you want to see everything at once, you can use this dropdown list to view
00:40them all on the screen at one time.
00:42Now we're going to add a few of these controls on to our form.
00:46First, I am going to use this Line control here.
00:49I'll click on it and I'll drag out a line to mark off some space at the top.
00:53I'll simply click and drag the line out.
00:56When the line is perfectly horizontal, it actually disappears completely, but
01:00when you let go, it will show up.
01:02So there is my first object, this line.
01:05Let's add a Rectangle around our Benefits to show that they all group together.
01:10I'll use this dropdown arrow and choose the Rectangle here.
01:13I'll click on it and I'll drag a box around all of our Benefits.
01:17I can also add a label to the top of our Benefits.
01:21This one here, with a capital A and the lowercase a, this is a label object;
01:26it's not connected to data.
01:28I'll click here and I'll add a label called Benefits.
01:33Once I get that put in, this little warning flag pops up saying that it's not
01:37actually connected to anything.
01:38That's okay though, we can go ahead and use this drop-down list and say Ignore Error.
01:43Now that we've got this group labeled as Benefits, I don't necessarily need it
01:46to say BenefitDental, BenefitMedical, BenefitRetirement.
01:50I can simplify these by double-clicking on each one and deleting the word Benefit.
01:57Now when I double-clicked on this, it actually toggled on the Property Sheet, so
02:01let's go ahead and close that back out again.
02:03I can add a logo to the top-left corner.
02:06I can do that by using this Insert Image button here.
02:09I'll say Insert Image and then Browse.
02:11Out of my Exercise folder, which is on my Desktop>Exercise Files, in the Ch 08
02:17folder, we'll find the NoObstaclesLogo.
02:20I'll click that and say OK.
02:22Now my cursor changes to a little picture icon and I can drag out a box where I
02:27want my image to be.
02:28Finally, I am going to add one more label across the top which will act as a title.
02:33I'll click on the Label and click again to add that.
02:36I'm going to add a label that says Training Department Employees.
02:41I'll go ahead and press Enter and again I'll dismiss this flag by saying Ignore Error.
02:46Finally, I am going to change the formatting of this.
02:48I'll enlarge the box quite a bit and I'll go to the FORMAT tab and change the
02:53Font Size to something like 20 and I'll try a Bold font, there.
02:59Let's go ahead and add one more control.
03:02Back in the DESIGN group, if I use this button here, there is an option called
03:07Option Group, it has an XYZ at the top.
03:10The Option Group is actually data-driven and what I want to do is use it to
03:15replace the job rating.
03:16I'll click here once and I'll click down below the JobRating field.
03:20The Option Group will create a list of features that we can choose from and then
03:24translate that into a numerical field that will save back into the JobRating.
03:28So instead of just displaying the number 1, 2, 3, 4 or 5 for our job ratings,
03:34we can use a radio button to select from.
03:37My label buttons, instead of our numbers, are going to be something a little
03:40bit more descriptive.
03:41For instance, I am going to type here, Needs Improvement, I'll go down to the
03:47next field Below Average, the next one will be Average, the next one will say
03:55Good and finally Outstanding.
03:59Go ahead and press Next.
04:01Access wants to know if we want one of these options to be a default choice.
04:05We can have it auto-populate or we can choose No, I don't want a default.
04:08I'll choose that option and say Next.
04:10The next screen matches the labels that we've previously selected with the
04:14values that will get stored in the database.
04:16These numbers are in the correct order, so go ahead and say Next.
04:19Finally, I can choose what I want to do with this data.
04:22I can either Save the value for later use or I can store the value that we
04:26select into a field in our database.
04:28I'll choose to store that as our JobRating. Go ahead and say Next and the last
04:33screen asks us how we want it to look.
04:35We can either have an Option button, a Check box, Toggle buttons and we can
04:40choose how we want the border around the edge to look.
04:43I am going to leave it on Etched and Option button.
04:46Go ahead and say Next one more time and we get to name our Option Group.
04:50I am going to call this JobRating. Go ahead and say Finish.
04:55Now we added an additional data-driven control to our form as well.
04:59Let's switch into Form View to see how these work.
05:01Now you can see that we've got our logo here at the top.
05:04I've got this bar separating the title from the rest of the form, I've got a box
05:08around our Benefits and I have this JobRating field here that duplicates the
05:13information that we're seeing coming out of the data table.
05:16If I cycle through my records, you can see that the JobRating matches the
05:19numerical value that's showing up for each employee.
05:22Now I can actually get rid of this field because we have that information in
05:26a more graphical way.
05:27I'll switch back into Design View one last time, I'll click on JobRating
05:31here and press Delete.
05:33Then I'll move this up into the position that it took.
05:38Now that our form is starting to take shape, I'm going to go ahead and save it
05:41up here on the Quick Access toolbar.
05:44Adding additional controls to your form, including boxes and lines to mark off
05:47discreet or related areas of the form, or images to add branding identity, can
05:51really take your Access database from blah to snazzy.
05:55But beyond simple graphical appeal, additional controls such as the Option Group
05:59can really aid in data entry tasks as well.
06:02You should explore some of the additional control types to see how you can
06:05incorporate them into your own forms.
Collapse this transcript
Understanding input boxes
00:00Typing into a text box on your form is the most common way to enter data,
00:05but it's also the way with the least control over what gets entered.
00:07I am going to open up the Training Department form that we've been working on
00:11and you'll notice that all of these fields; the Name, the Building, Department,
00:15Phone Number and Salary fields are all text boxes.
00:19We can essentially type whatever we want here as long as they're allowed by the
00:23table's underlying design.
00:24Notice that the Status field is a combo box though, it has a dropdown
00:28list attached to it.
00:29That's because we've previously defined that field in the table as a lookup field.
00:34We can get the same effect for other fields here in our form without going all
00:37the way back and editing our table.
00:39I am going to switch into Design View by clicking on the bottom half of the View
00:43button and choosing Design View.
00:44I am going to click on this Building field here.
00:47And if I right-click, you'll get a pop-up menu, and the top option here says Change To.
00:52We can change this text box to a Label, a List Box or I am going to choose Combo Box.
00:59When I change it to a Combo Box, we see the dropdown arrow here.
01:03Let's go back into Form View and see how this looks.
01:06I'll switch my view and we'll see that we have the functionality here, but there
01:10is nothing actually here to choose from.
01:12So let's go back into Design View and we'll fix that up.
01:15Once again, I'll change my view and I'll open up the Property Sheet for the Combo Box.
01:19I am going to make sure that it says Building here, this is the Combo Box.
01:24On the Data tab, on the Control Source, it's currently set to Building.
01:28This is where the data is getting saved to in my table.
01:32The line below says Row Source.
01:34This is where the fields that are going to populate the list will come from.
01:37I am going to click here and click on the Build button on the far right to build
01:42a query that will generate that list.
01:44When I click Build, we put into a new query design editing environment.
01:49You can see on the tab up here that it says Training Department Employees: Query Builder.
01:53This is a query that's actually embedded inside of the form we were working on;
01:57it won't show up in our Navigation pane.
02:00Here, we can pull out the Show Table window and choose which tables we want to include.
02:05I am going to pull in the Employees table and say Close.
02:09Then I am going to add the Building field.
02:11We can look at the datasheet to see how this looks and this is not quite the way
02:16I want my dropdown list to look.
02:17So go back into Design View and I'll turn on this Totals here which will group
02:21all of the same values together into a single entry.
02:25Once again, let's review the datasheet and this list is looking much better for my dropdown.
02:30So I'll switch into Design View, I'll close the query that will ask me if I
02:36want to save the changes to it and I will say Yes.
02:39That will take us back to Design View for our form.
02:42Notice that the Row Source is now populated with this SELECT statement.
02:45That's the SQL code for the query we just built.
02:49Now let's go into the Form View and look at how it works.
02:52I'll switch my View, go back to the Building field here and use this drop-down list.
02:58Now I can make a selection of all of the buildings that are present in
03:01my Employees table.
03:03This list is being dynamically generated from all of the values that appear in
03:06our Employees table.
03:08If a new building is added to the Employees table, that option will
03:11automatically appear in our Combo Box as well.
03:14By converting this text field into a Combo Box, we can dramatically reduce the
03:18chances of somebody mistyping the name of the building or adding a building
03:21that doesn't even exist.
03:23By leveraging these types of controls, you can have Access help eliminate the
03:27potential human errors that can destroy your database's integrity.
Collapse this transcript
Recording navigation
00:00Scrolling through the records on a form using the navigation buttons on the
00:04bottom is not a really great experience.
00:06Let's open up the Training Department Employees form and you'll see what I mean.
00:10Let's try and find one of the employees here in the Training Department, his
00:13name is Timothy Tanner.
00:15I'll click on the next Record button until I find him and I will have to keep
00:19scrolling through and there he is on record number 12 of 17.
00:25It's a good thing he wasn't record number 112 or we'd be clicking for quite awhile.
00:29We can dramatically improve this functionality by creating a specialized Combo
00:33Box that will jump us to the record we want.
00:35I am going to start that process by switching my View to Design View.
00:39First, I want to give myself some more room on the right side of my form.
00:43I am going to click over here and drag to increase the background area of my form.
00:47Next, I'll grab the Combo Box control out of the Controls Group on the Design tab.
00:52I'll click it once, you'll notice that my cursor has changed now and I'll click
00:56once to add the Combo Box to my form.
00:59The combo box Wizard starts up and gives me three options.
01:02I can either choose to have the Combo Box get values from a table or query.
01:07I can type in a list of values that I want to display or, and this is the one
01:11that we're going to want, find a record in my form based on the value that I
01:16selected in my Combo Box.
01:17Go ahead and choose that third option and press Next.
01:21Access then needs to know which field we want to show up in the box.
01:24I'll click on LastName and add that over to my selected fields.
01:28Go ahead and say Next, it shows me a preview of what that list will look like.
01:33Go ahead and say Next again, and now we can give a Label to our Combo Box.
01:37I am going to call this Search.
01:40Go ahead and say Finish.
01:41I am going to make my Combo Box a little wider by dragging it here and now I'll
01:46go back into Form View and test it out.
01:49In my new Search box, I can use the dropdown to show a list of all the
01:54employees in my training department.
01:55I can scroll through and choose Timothy Tanner's last name to jump right to his record.
02:01I can also use this to start typing it.
02:03So instead, if I just type an S, it will jump to Spencer.
02:07If I continue typing a T, it will jump to Strickland.
02:10If that's the employee that I want, I simply press Enter and you'll see that my
02:14record updates to display that employee.
02:16Adding a dynamic search box is a great way to provide a quick navigation to a
02:20specific record, without having to know his position in the record set.
02:24And because the list is built off of a query, the dropdown options
02:27automatically update whenever new employees are added to your database.
02:31Once it's set up, it just works and will continue to update as your database grows.
Collapse this transcript
Adding buttons
00:00Adding buttons to your forms brings in another level of interactivity.
00:04The Button wizard will help us attach the act of pressing a button to a specific
00:08action or result that we want to take place.
00:10Let's add a few buttons to our Training Department form.
00:13I can open it right into Design View by right-clicking and saying Design View.
00:17Up on my Controls Group here, I can choose the Button button, that's this one
00:22here with the Xs in it.
00:23I'll click it once to grab one and I'll come down here into my form and I'll
00:27click to add a button.
00:29The Command Button Wizard starts up and gives us lots of options for things that
00:32we can do when we press this button.
00:34We have a category here called Record Navigation.
00:37On the right is a list of Actions that are in that category.
00:39For instance we can find the next record or go to the first or last record.
00:45The Record Operations category has things like adding records, deleting records
00:50or printing records.
00:52We have Form Operations here, we can close or open a form or we can print a form.
00:58Report Operations will email a report or open a report or send a report to a file.
01:04The Application category will allow you to quit Access altogether and the
01:08Miscellaneous category will allow you to run macros or queries.
01:11Let's add a few buttons onto this form.
01:14First, I am going to go to Record Operations and I am going to choose Add a New Record.
01:19We'll go ahead and say Next.
01:22Access then needs to know how we want our button to look.
01:24Do we want to include a Picture on the button or do we want Text.
01:28I like the Text option because it allows me to be more specific about what
01:32happens when I press the button.
01:33So instead of just Add Record, I am going to change this to Add Employee.
01:38Go ahead and say Next.
01:40We can give it a name if we'd like, but I'll just accept the default here and
01:44say Finish, and the button updates here on our form.
01:47Let's add a couple of more buttons.
01:48I'll go back up to the controls and grab a new button and I'll drop it into my form.
01:53This time we're going to choose Record Operations, Print Record.
01:58Go ahead and say Next and the text for this one is going to be Print
02:02Employee's Details.
02:05Go ahead and say Finish and that button gets added to our form.
02:08Let's do one more button.
02:10I'll grab another one.
02:11I'll click down here to add.
02:13This time I am going to go to Form Operations and I am going to say Close Form.
02:19Go ahead and say Next and the text for this button is going to say Close Data Entry Form.
02:25Go ahead and say Next and then Finish, that adds this button as well.
02:29Okay, we can style our buttons a little bit by going up to the FORMAT tab and
02:33for instance I've got the Close Data Entry Form button selected, I want to make
02:37that one called out.
02:38so I am going to go up to the Quick Styles and change it to an orange color
02:43here, may be this moderate Effect one, that will make it orange and stand out.
02:46I can also change its Shape if I'd like, from this one to may be a square button.
02:51If I wanted, I also have Shape Fill options here where I can change the fill color.
02:55I can change its Outline, Color and down here its Thickness, I can also add
02:59Special Effects such as Shadows and Glows and Beveled Edges.
03:03I am going to leave all of those as the defaults.
03:06Let's go ahead and move this button down to the form.
03:08I'll just scroll down and I'll move this down to the bottom corner.
03:11Then I'll scroll back up and I'll move these buttons up towards the top and I'll line them up.
03:18I'll go ahead and make the Add Employee button a little bit wider so that it
03:21matches the Print Employee's Details button's width.
03:24That's looking pretty good, so I am going to go ahead and switch back into Form View here.
03:28Now we can go through and save our form and I'll try them out.
03:32The Add Employee button will do the same thing as if we have gotten all the way
03:36down to the bottom here and press this New (blank) record button.
03:39If I want to add an employee, I simply press this button.
03:42I can print an employee's details by pressing this button here and the
03:46Print dialog box opens.
03:47I'll go ahead and press Cancel.
03:49And finally, when I'm done with the form, I can close this data entry form right
03:52here with a very explicit button on the form.
03:55People love pressing buttons, they are instantly familiar and they can be
03:58really intuitive to use.
04:00Using the Text option to be explicit about what the button will do when clicked
04:04helps users feel comfortable using your database.
04:07The wizard gave us a few options of the types of things that our buttons can do.
04:10However, later when we create our own macros, we can come back and attach those
04:14to the buttons as well for even more functionality options.
Collapse this transcript
Assigning tab order
00:00I'll admit that I'm addicted to my keyboard.
00:02I try and keep my hands off the mouse as much as possible when entering data
00:06using the Tab key to move from field to field.
00:08However, watch what happens when we've made as many changes to the layout of our
00:12Training Department form as we have.
00:14I am going to open up that Training Department Employees form that we've been working on.
00:17And you'll notice that the FirstName field is currently highlighted.
00:20I am going to press Tab to move to the LastName field, but you'll notice that it
00:24actually jumps all the over to building.
00:26I'll press Tab again and it goes back to LastName.
00:29Tab again goes to the Department and so on.
00:31You can see that the tabs are jumping all over the screen.
00:35We need to take care of this problem and we will find the tool that we need by
00:39switching into Design View here on the ribbon.
00:41Over on the ribbon on the far right, you'll find a button called Tab Order,
00:45I'll go ahead and press that and Access lists out all of the tab stops in their position.
00:51You'll notice that it starts with FirstName, then goes to Building, then
00:54LastName and then Department, so these are all out of order.
00:57There is a button on the bottom that says Auto Order and when I press it, Access
01:01will take its best guess at the right order of things, but you can see that it
01:05really doesn't get it right in our layout.
01:07It goes from the Image to the Combo Box which is our search over here on the
01:11right, then it goes to the FirstName, then LastName, then over to Building, then
01:16over to the button over here to the right of it, so we need to manually manage
01:19these tab stops on our own.
01:21Let's go ahead and put them in the right order.
01:23I am going to select FirstName by clicking on it and then I'll click and drag to
01:27move it to the first position.
01:29Below that will be LastName, I'll click and drag it up.
01:32After I get done typing in the LastName I want to move down to the phone number,
01:37so I'll select Number and drag that up as well.
01:39After the Phone Number, we can go to Building and then Department.
01:44There is our Building, I'll move that up and there is Department and move that one up.
01:49After I get done with the Department, I'll jump over here, Salary, Status then JobRating.
01:54Salary and Status are already next to each other, so I'll drag over both of
01:58those to select them both and I'll drag them up and put them below Department.
02:02The JobRating, you'll remember, we put in using an Option Group;
02:05it's actually this Frame16 here right now because we didn't rename it.
02:09I'll click that and drag and drop it below Status.
02:12After we get done with JobRating, we'll move over to our Benefits;
02:16Dental, Medical then Retirement.
02:19Here they are here, Dental, Medical and Retirement;
02:21I'll drag over all three and put them below the Frame16.
02:26Finally after that, it goes to the Image up in the top-left, I'll drag that to
02:30the very bottom, then the Combo Box, which is again our Search box here and
02:35then the three buttons, the Employee's button, the Print details and the Close button.
02:39Let's go ahead and say OK to accept these changes.
02:43Now if there are particular controls that you don't even want to be in the Tab
02:47rotation, you can remove them with a property on the Property Sheet.
02:50For instance, I don't necessarily need the Search box to be part of that Tab Order.
02:54I'll click on the Search box and open up the Property Sheet.
02:58On the Other tab of the Property Sheet, there is a property called Tab Stop
03:02and it's set to Yes.
03:03I'll click on it and in the dropdown, I'll change that to no.
03:07Go ahead and close the Property Sheet.
03:09We can go ahead and save our changes and we'll switch into Form View to test it out.
03:14Again the FirstName is highlighted and I'll press Tab and it moves over to the LastName.
03:19Then again, down to Phone Number, next Tab goes over to Building then Department,
03:24then to Salary, Status, JobRating, over to our Benefits, then up to the buttons,
03:30the second button here.
03:32Tab again moves down to the Close button.
03:34When I press Tab one more time, it'll change the next Record, now we're on
03:38Record 2 and it goes back to the FirstName position.
03:41Notice that the Search field was not part of that rotation.
03:44Even though, tabbing through the fields might not be the way that you
03:47personally would interact with the form, it's important to consider the ways
03:50that lots of different people work and try and provide alternative methods that
03:54accommodate different styles.
03:56Making sure that your Tab Stops are in a logical and predictable order can mean
04:00a world of difference between a database that is a chore to use from one that is pure joy.
Collapse this transcript
Checking out the More Forms options
00:00Most data-driven forms display only a single record at a time.
00:04However, there are additional form types that you can choose when you'd like to
00:08be able to work with several records.
00:10Up on the CREATE tab in the More Forms group, we have two that I'd like to take
00:14a look at; Multiple Items and Split Form.
00:17Let's first make a Multiple Items form based off of our EmployeePhone Crosstab
00:21query that we created earlier.
00:23I'll click that in the Navigation pane, go up to More Forms and then select Multiple Items.
00:29Access generates a Multiple Items form that we can scroll through to see all of
00:34our employee phone numbers.
00:35If the Property Sheet opened, go ahead and close it down here.
00:39Now we can go ahead and start making changes to your form.
00:43Right now we're in Layout View and I can see that by looking at the top here
00:47where it says FORM LAYOUT TOOLS.
00:48In Layout View I can adjust all of the columns at once by clicking a single
00:52representative field.
00:53I'll quick on this FirstName cell here, David, and click on the bottom and drag up
00:57to make everything shorter.
00:59Now I'll start making everything a little bit less wide, so I can fit more
01:03information on the screen.
01:04I'll simply click on their cells and drag their right edges.
01:07We'll do the same thing for the Cell phone number, I'll click and drag to the
01:10right, Emergency numbers, make those shorter, Fax, Home and the Office numbers.
01:21Now I can also rearrange my columns by Shift+Clicking to grab the header row as
01:26well and then click and drag to reposition.
01:29I am going to move Office phone to the very beginning right after LastName,
01:32but before Cell phone.
01:34Notice as I am dragging I get a pink line telling me where it's going to go.
01:38When I let go the Office numbers move over and everything else readjusts.
01:42Now let's start taking a look at some other formatting.
01:45Access tends to put boxes around every single field and it drives me crazy, it
01:48makes it much more cluttered.
01:50Let's go ahead and click on David here, I'll Shift+Click on this last box here
01:54to select all of my cells.
01:55Then I'll go to the FORMAT tab, Shape Outline then I am going to change the
02:01Outline to Transparent to get rid of those boxes.
02:03I can click off to see what it looks like.
02:06Now let's change some of the stuff up here in the header.
02:09First I am going to change the title, right now it says EmployeePhone Crosstab,
02:12which was the name of the query we've built it off of.
02:15I'll simply double-click to edit it and I'll change it to Employee Phone List.
02:22Now I'll change this graphic here, this will be our logo for the
02:25NoObstacles company.
02:26I'll click on the graphic, go to DESIGN and press this Logo button here, then
02:32I'll browse out to my Desktop to find my Exercise Folder and in Chapter 08 I've
02:37got the RecycleBug logo, go ahead and say OK and that will put it in.
02:42But we can see that it's cropped so we need to adjust some Properties of this image.
02:47I'll go to my Property Sheet and in the picture Size mode right now it's set to
02:50Clip which is a cropping mode, I am going to change it to Zoom so that it
02:55shrinks to fit in the box.
02:56Now I'll change the background color here to match the logo, so it all blends seamlessly.
03:01I'll click on the blue area over here so that this portion is highlighted, and
03:05I'll go up to the FORMAT tab, Shape Fill and I'll change it to this white swatch here.
03:11Finally, I want to get rid of these boxes over here on the left side.
03:14These are record selectors.
03:15When you click on them essentially you're selecting the record.
03:18In order to get rid of those we need to change to the Properties for the form.
03:21If it's not selected here, you can use the dropdown to select it from the list.
03:26Now we're going to find the Record Selectors property here and change it from Yes to No.
03:31That will clean up the display quite a bit.
03:33Let's go ahead and close the Property Sheet and take a look and that's
03:37looking nice and clean.
03:39Let's go ahead and close this form and when I am prompted I'll go ahead and save
03:43it as Employee Phone List.
03:47Now let's create a Split Form.
03:49I am going to build a split form off of my Orders table.
03:52I'll click it in the Navigation pane, go up to the CREATE tab, More Forms and Split Form.
03:59A split form gives you the best of both worlds.
04:02You get a regular form up here at the top where you can see the details for an
04:05individual record and then on the bottom you get a datasheet view where you can
04:08see that record in context with the other records around it.
04:11I've got a splitter bar here in the middle here, but I can drag up if I want to
04:15see more records at the bottom, or I can drag down if I want to see more of the
04:20Details section at the top, I'll move it back here to the middle.
04:23We can adjust some of the properties for this as well.
04:26This time I'm going to switch into Design View to do that.
04:29I'll use my View button and go to Design View.
04:32Let's take a look at some of the properties for this form.
04:34I'll go to the Design tab, open up my Property Sheet again and then right now
04:39I am looking at the properties for the Form here.
04:42I'll scroll down on the Property Sheet and we'll see several properties dealing
04:46with the Split Form.
04:47I can see how much room I'm allocating to the datasheet on the bottom.
04:51I can adjust the position of the datasheet, may be I want it on the top or
04:56the left or right side.
04:57I'll leave it at bottom.
04:58And I can also turn that Splitter Bar on or off.
05:01If I turn it off my users won't be able to adjust the Spacing, I am going to
05:04leave it set to Yes.
05:05Let's go ahead and clean up the header now.
05:08I am going to make it look like the Employee Phone List, I am going to click
05:11up here in the headers section and on the FORMAT Tab we'll go to Shape Fill
05:15and change it to white.
05:17We'll go ahead and click on this image here, then go to the DESIGN tab, press
05:21the Logo button again and we'll use the same RecycleBug logo, that way we have a
05:25consistent brand experience.
05:27Again, I'll change its Size mode from Clip to Zoom.
05:32The title here is fine, I'll leave it saying Orders, but now I want to adjust
05:36some of these boxes here in the Details section.
05:39I am going to click on customer.
05:40Right now, on our table we're storing the customer's ID number which doesn't
05:43really aid order entry.
05:45I would have to know the ID number for every single customer and that's just not practical.
05:49I can make this a better experience by right-clicking on this text box and
05:53converting it to a Combo Box.
05:56Then if you remember from the Combo Box movie, we need to go to the Data tab and
06:00give it a Row Source so it has a populated list when we click on the down arrow.
06:04I'll click on the Row Source field here and press Build to build a query
06:08to generate that list.
06:09I'll go to the Customer's query, I'll choose the Customer's table and press Add and Close.
06:15Then I'll pull in some fields from the table;
06:17CustomerID, FirstName and LastName.
06:21Finally, I want to sort this list by LastName Ascending so that it's alphabetized.
06:26I'll close the query, I'll save the changes and that will return me back to my form.
06:32Now there's one last change that I need to make here, I am going to go to
06:36the FORMAT tab, still on the Combo Box and I am going to change Column Count here from 1 to 3.
06:41That way it shows the ID number, the FirstName and the LastName for my customers
06:45when I use the dropdown list.
06:46Let's go ahead and close the Property Sheet.
06:48I'll go ahead and save my form here. I am going to give it the name Orders
06:53that's fine, go ahead and say OK and let's test it out.
06:56I'll switch into Form view and now I'll press the New Record button here at the
07:00bottom to enter a new order.
07:02When it comes time to enter in the Customer, I can use this dropdown list to
07:06select the Customer, for instance I'll choose Jasmine Tillman.
07:10Now it puts in her ID number here and I can continue filling in the record.
07:15These additional form types give you even more options when you want to review,
07:19add or edit the records in your database, all while unlocking the ability to
07:23completely customize the interface to match your needs and tastes.
Collapse this transcript
Creating a navigation form
00:00You might have noticed that our Navigation pane down on the left side of the
00:04screen is growing at a steady rate.
00:06Pretty soon we're going to have lots of objects and remembering exactly which
00:09one you need to use for a particular task might start to become more difficult.
00:13We can help users get around our database and easily move from task to task by
00:17organizing the relevant forms into a single tabbed interface called a navigation form.
00:21We can create a navigation form by going to the CREATE tab in this Navigation
00:26button here in the Forms group.
00:28If I click on the dropdown I'll notice I have lots of options here.
00:31I can have tabs across the top, tabs on the left or right side or multiple
00:35levels of tabs across the top, he left end top, or the right end top.
00:39I'm going to choose the Vertical Tabs, Left.
00:43Access creates a Navigation Form and it gives me this drop area over here
00:47where I can add my forms.
00:48Let's scroll down on my Navigation pane to choose some.
00:51I am going to first grab the Orders form and move it up here and drop it on Add
00:56New, that adds the Orders Form here into my Navigation Form.
00:59Then we can also grab a report. I am going to take my Products Report so we have
01:05it for a handy reference. I'll drag and drop it right below.
01:08Then we can grab our Employee Phone List, drag and drop it there, and finally our
01:13Training Department Employees form, I'll drag and drop it there.
01:17Now I can go ahead and close the Navigation pane to get it off my screen and we
01:21can start editing the layout here.
01:22I'm going to choose this logo and on the DESIGN tab press the Logo button here.
01:27We're going to choose from our Desktop in the Exercise Files folder, in the
01:33Chapter 08 folder, our RecycleBug logo, go ahead and say OK.
01:37Then I need to change its Size mode so I'll open up the Property Sheet and go to
01:41the Size mode for the image and change it from Clip to Zoom.
01:46I'll change the Background to white;
01:47I'll click back here in the blue area and on the FORMAT tab, Shape Fill, white.
01:54Notice that I can also change it in the Property Sheet here;
01:56it's the Back Color property.
01:58This is the code for white or I can press the Build button here to get to
02:02the same color chips.
02:03I can also change the styling of my buttons.
02:06I'll press the Orders button here and then change to the FORMAT tab.
02:09Under Quick Styles, I can choose a Color Style.
02:12I'm going to choose this green option here, the Subtle Effect, Green Accent 6.
02:16I can also change its shape if I'd like. We can make it a rounded rectangle.
02:20I'll do the same for the other buttons here.
02:22I'll change the Quick Style to green and this shape to this rounded rectangle.
02:26I can select multiple buttons by holding down the Shift key and selecting all of them at once.
02:32Then I can go to Quick Styles and change them all of it at one time, just like that.
02:38Finally, I am going to change the name up here at the top;
02:41right now it says Navigation Form.
02:43I am going to double-click on that and say No Obstacles Database.
02:46All right, we can go ahead and save our form, I'll press Save up here.
02:52Go ahead and name it Navigation Form and say OK and I'll close the Property
02:56Sheet and switch my View on the HOME tab, switch to Form View.
03:00Now I can click through these buttons and move to my database.
03:04First I can click Orders to get to my Orders Form, then I can click Products
03:08which will give me the Products Report, which I can scroll through and see all
03:12my products in the company, the Employee Phone List will bring up my multiple
03:16items form and I can scroll through that to see all of my employees.
03:19Or I could press Training Department Employees to affect some of their settings.
03:23The Navigation Form allows you to link, form and report objects, it might
03:27even eliminate the need for you to go to the Navigation pane to get around your database.
03:32This will help you accomplish your day-to-day management operations, quicker and easier.
Collapse this transcript
9. Creating Reports
Introducing reports
00:00Reports prepare your data for printed output.
00:03They gather input records from tables and queries and then add formatting and
00:07page layout capabilities in order to organize the data and make it more legible.
00:12As you can see on the CREATE tab up here, there are lots of different ways that
00:16we can create a report.
00:18They share many of the same design principles that we have already seen when
00:21creating forms, including the same use of control objects and very similar
00:24design and layout views.
00:26Easiest way to get started creating a basic report is to use the one-click
00:30Report button here on the CREATE tab.
00:33First, click on the table or query that you want to build the report off of.
00:37I am going to choose the EmployeePhoneNumbers query that we constructed earlier
00:40on the course and then, go up here to the ribbon and press the Report button.
00:44Access generates a basic report for our data.
00:47Just like with forms, we can use the Layout View that we are in now to all alter
00:51the spacing and positioning of the report's fields.
00:53The dashed line around the border here indicates the extent of my page
00:57margins and you can see that we have some fields that are spilling over onto
01:00the adjacent pages.
01:01We can fix that by adjusting these widths.
01:04I'll click here where it says Zachary, which is our first employee.
01:07That will select the entire column.
01:09Now I can adjust the width of the entire column here.
01:11I'll do the same thing with the LastName and the Phone Number.
01:18Just like with forms, Access likes to surround every field here in our
01:21reports with a box.
01:22I find this to be distracting.
01:24So we can go ahead and remove these boxes by selecting each column.
01:27I'll go ahead and select this Office and I'll Shift+click here to select all of the columns.
01:31I'll go up to the FORMAT tab and in Shape Outline I'll change it to Transparent.
01:37Now we can take a look at what this form looks like in a printed page by
01:40switching to the HOME tab and going to the bottom half of the View button here
01:44to switch into Print Preview mode.
01:46That will give us what the form will look like, set up on the printed page.
01:50I can click the zoom out button to see the entire view.
01:54Then when we are done with Print Preview, we can press this Close Print Preview
01:57button here to return to our editing mode.
02:00So that's what Access created for us without asking for any input.
02:03One area, that I think could use some improvement with our phone number
02:06report is that the fact that each of our employees is listed over and over
02:09for each phone number.
02:11We can clean that up a bit with just a few more steps by using the report wizard instead.
Collapse this transcript
Using the Report Wizard
00:00We can get more control over the layout of our report by allowing the Report
00:04Wizard to walk us through the process of collecting and organizing our data.
00:08Let's create another employee phone number report using the wizard.
00:11I am going to go up to the CREATE tab and go to Report Wizard here.
00:17The Report Wizard starts and I get to choose the source of my data.
00:20In the dropdown notice that you can choose from any of your tables or, scrolling
00:24down, any of your queries.
00:25I am going to use the EmployeePhoneNumber query that we created earlier.
00:29Now we can add the available fields to our selected fields to use in the report.
00:33The order here is important though, so make sure you choose LastName and move
00:37that over and then FirstName, move that over then, Number and then Type. Go and say, Next.
00:45Access has identified the relationship between our names and phone numbers and
00:49suggests that this is a layout where we group our last names together and then our
00:53phone numbers will appear under that.
00:55The other option here, by EmployeePhone, will list them with each phone number on its own line.
00:59I am going to choose by Employees.
01:02Go ahead and say Next.
01:03We can add additional groupings here if we'd like, but we don't need to do that,
01:06so go ahead and say Next.
01:08Next, we are going to sort our numbers based off of their type, so they stay
01:12in a consistent order.
01:14Go ahead and say Next.
01:16We have some options here for how our report will lay out.
01:18I can choose either of the Stepped, Block, or Outline format and you see a sort
01:23of preview here on the left.
01:24I am going to choose Stepped.
01:26We can choose our Paper Orientation as either Portrait or Landscape.
01:29I am going to leave it as Portrait.
01:31And finally, we have a checkbox here to adjust the field width so that all the
01:35fields fit on a page.
01:36I am going to go ahead and leave that on.
01:39Go ahead and say Next.
01:40We can give our Report a title.
01:42I am going to call it Employee Phone List and finally, we get to choose whether
01:46we want to preview the report or modify the design.
01:49I'll leave it on Preview and say Finish and that will take us into Print Preview
01:53view with our report.
01:55Even though this is the same data as the report that we used in the previous
01:59movie, the report has a very different look.
02:01Now each employee is only listed a single time and their phone numbers are
02:04listed multiple times below that.
02:07Now we have a different problem though.
02:09The alternating row color that Access puts in here, is making it a little
02:12difficult to distinguish each section.
02:14Let's continue refining the layout here, using the Layout tools.
02:17I am going to close the Print Preview with this button here on the ribbon.
02:21That will switch me into Design View.
02:23Using the View button here, I'll change it back to Layout View and if it's open,
02:28I am going to close the Field List to give myself some more room.
02:31Now we need to remove the alternating row colors.
02:34I'll click on this first one here and on the FORMAT tab, Alternating Row Color,
02:39I am going to change that to No Color.
02:41There is also an Alternating Row Color on our names.
02:44So I'll click one that's active, Alternate Row Color and again No Color.
02:49Now I can change it to a standardized color for our names, so that every
02:53single name has a different color bar, that'll help separate the different
02:56sections of our report.
02:57Instead of an Alternate Row Color, I am going to go up to Shape Fill and choose
03:02this light green color here.
03:05Now I can see that there is white background between my names.
03:08I'll click on the last name here, Shift+click on the first one and change their
03:12background color to the same green.
03:14Finally, I can make our fonts bold here and I want to give them a little
03:19bit more space above.
03:20So what I can do is drag down to increase the width of the bar and then go up
03:25to the top edge and when I get this double-headed arrow, I'll drag down to
03:28reposition that towards the bottom, so that I have a larger bar separating each employee's name.
03:33Now that our employees are taken care of, let's go ahead and finalize our
03:36report by adjusting some of the options up here in the header.
03:39First I am going to click on this Employee Phone List and I am going to move it
03:44over using my arrow keys.
03:45That will give me room now to put in a logo.
03:48On the DESIGN tab, I'll press the Logo button here then I'll browse out to
03:51my Desktop and into my Exercise folder, we are in Chapter 9 and I am going
03:55to choose the RecycleBug logo, go ahead and say OK and Access puts that in the background.
04:00Now I'll change the background color of my header by clicking over here
04:03to select the header.
04:04I'll go to FORMAT>Shape Fill and choose White.
04:09Then I'll change the color of this bar here to a darker green, Shape Fill and I
04:14am going to choose this dark green down here.
04:16And finally, I am going to change the color of the labels by selecting each one
04:20by Shift+clicking and changing their font color here to white, I'll make them
04:25bold so they stand out more and then, I'll adjust the names here by
04:28double-clicking and putting in some spaces. Great!
04:33So that's looking pretty good.
04:34Let's go ahead and see what this looks like on the printed page.
04:36I'll go back to the DESIGN tab here and switch my View to Print Preview. Now I
04:42can see what this looks like.
04:44I can zoom out to see the whole page, zoom in, scroll up and down to take a look
04:48and when I am done, I can close Print Preview.
04:50Let's go ahead and save the changes here and then I'll save it down in our
04:54Navigation pane, here.
04:55The Report Wizard was able to get us a little closer to report that is formatted
04:59in the way that we would like.
05:00With a little additional help tweaking the results in Layout View, we were able
05:04to arrive at a neatly formatted phone list that could be printed out and
05:07distributed to our employees.
Collapse this transcript
Creating a report in Design view
00:00For complete control over your report layout, you're going to want to explore
00:04the Report Design View.
00:05Many of the features that we went over with form design also apply to the
00:09design of reports, which make it easy to apply what we already know.
00:12However, reports have a structure that is distinct from most forms which adds
00:16another aspect to their construction.
00:19Most forms display only a single record at a time.
00:22Reports display many records, one after another.
00:25Let's open up that Employee Phone Number report and I am going to open that in
00:29Design View by right-clicking on it and going straight to Design View.
00:32Now you might be surprised at how short this is.
00:35The nature of a report is that there are several sections but they get stacked
00:38one on top of another over and over again.
00:41We only have to design each piece of the stack one time and Access just repeats
00:45it as many times as it needs.
00:46At the top of our report, we have the Report Header section, that's this area right here.
00:51The report header will only appear at the very top of the very first page in the report.
00:56After that, we have a Page Header.
00:58The Page Header section will appear at the top of every page.
01:01Then we have the LastName Header.
01:04The LastName Header appears every time we have a new employee for our report.
01:07Below the LastName, we have got this Detail section.
01:11The Detail is the meat of our report.
01:13It's where all of our phone numbers are going to appear.
01:15If an employee has three phone numbers, we'll get three detail sections
01:19stacked on top of each other before going to the next employee which will have a new header.
01:24Then we'll have phone numbers over and over again for that employee.
01:27Once we get to the bottom of the page, we get a Report Footer section.
01:31The Report Footer section is here and currently has calculated boxes that will
01:35give us the date stamp and the number of pages.
01:38Then we go to the top of the very next page.
01:40That gives us a new page header, then a name header for our employee, phone
01:44number, phone number, phone number in the Detail section, the next header for the
01:48next employee, more phone numbers and so on.
01:50When we run out of phone numbers, we get this Report Footer section.
01:54Our report doesn't currently have a footer.
01:56But if it did, it would appear at the very bottom of the very last page.
02:00Let's make some adjustments to our report now.
02:02I'm going to take our Detail section and right above where it says Page Footer,
02:06I am going to get this double-headed arrow.
02:08I'll click and drag it down just a little bit here.
02:11Now let's see how that affects our report.
02:13I'll switch my view into Print Preview mode and you can see that we get a gap
02:18below every single phone number and since that repeats over and over and over
02:21again, that can dramatically increase the spacing and layout of our report.
02:25Typically you are going to want to keep your report design as compact as
02:28possible so that your data rows follow one after another.
02:31Let's go back and close Print Preview, that will take us back to Design View.
02:36The typical workflow when working in Design View is going to have you open up
02:40some space here in a Detail section for example and the move fields around.
02:45Then when you get everything organized, the way you want it, you will go back and
02:48collapse everything down as tight as possible.
02:50I am going to add a line here that will separate our phone numbers.
02:53In order to do that, I am going to work in this Detail section.
02:57I am going to highlight this Type and Number field and using the arrow keys, I
03:01am going to move them down to give me some room.
03:04Then I'll deselect them by clicking over in the edge.
03:06I am going to go up to the Controls group up here and I'll scroll to the list
03:11until I find the Line here.
03:12I am going to click on my form and I am going to drag out a straight line,
03:17starting at the left side and going all the way over here to the right.
03:20When your line is perfectly horizontal, it actually looks like it disappears.
03:23If it does then, go ahead and let go of the mouse and you have got a perfectly
03:28straight line all the way across.
03:29Now let's go ahead and change the color of it.
03:32I'll go to the FORMAT tab and under Shape Outline I am going to choose this
03:36medium green color over here on the right.
03:38Now I am going to move it up, so it's tight against this detail section.
03:42I'll press the up arrow key a couple of times until it's all the way at the top.
03:46If I press it too many times, it'll jump up into the LastName Header.
03:50I can see it's highlighted right up here.
03:52I'll press down one time to move it to the other section.
03:55Now I am going to highlight Type and Number again and I am going to use my up
03:59arrow keys to move them all the way up to the top.
04:02Once I have got those tight against the edge, I am going to grab the bottom of
04:06the Detail section here and drag that up again to sandwich it all together.
04:10Now let's go ahead and change our view again.
04:12Go to DESIGN, go to View and go to Print Preview.
04:15Now you can see we have a line separating every single one of our numbers.
04:19Let's go ahead and close the Print Preview to return to the Design view.
04:22So other than the structural difference, the design of report is almost identical
04:25to the design of forms.
04:27You have the same tabs going across the top, you have the DESIGN tab with our
04:31controls in it, our header and footer options are here, we can add existing
04:34fields from our record set or we can open the Property Sheet to explore the
04:38properties for every single option just like in Forms.
04:40On the ARRANGE tab, over here on the right side, we have our options for
04:44arranging our items, for aligning them to each other or for bringing them down
04:47in front of each other or sending them behind each other.
04:50On the FORMAT tab, that's where I am going to go to adjust colors and fonts
04:54or set images here.
04:56Unlike Forms we have a new tab here called PAGE SETUP.
04:59The PAGE SETUP tab has options for setting our page size and adjusting the
05:02orientation of our paper.
05:04So overall, building reports is nearly identical to constructing forms, we'll use
05:08the same tools and techniques that we've already been practicing.
05:11Keep in mind the stack nature of the report structure with the repeating
05:15sections and you'll be well on your way to creating some very attractive and well-organized reports.
Collapse this transcript
Grouping and sorting records
00:00Understanding the grouping and sorting options available when setting up your
00:04reports, will allow you to have complete control over the organization, layout
00:08and styling of the data;
00:10doing this in layout view will allow you to experiment with the grouping and
00:13sorting of your records into logical arrangements.
00:15We are going to create a new report that takes a look at the total number of
00:18products that NoObstacles has sold.
00:20We'll start by taking a look at this query that I set up called Products Sold.
00:24I'll double-click on it to run it and you will see that we are pulling
00:28information about the department and category of each of our products.
00:31Then we are calculating the total number sold and the overall value that they
00:34have contributed to our bottom line.
00:36By switching to Design View, we'll see that this is a Totals query and in this
00:40fourth column, I have got the Total Quantity Sold and this one over here I have
00:44got the Total Value.
00:46Let's go-ahead and close this query and we'll start our report.
00:49I am going to make sure that I have got the query still selected here in the
00:53navigation pane and I am going to go up to CREATE and I am going to press
00:55the Report button here.
00:58That will generate a basic report and set us up in Layout View.
01:01Let's go ahead and adjust these sizes so that we are not running off the page.
01:04I'll take my Department field and shrink it down and we'll do the same thing
01:06with Category, shrink it down.
01:10Now everything is fitting onto a single page.
01:12I am actually going to give some more room to Product, because some of my
01:14product names are quite long.
01:17I'll adjust that out a little bit more.
01:20Right now, I am seeing a single line for every record that's being fed from the query.
01:24If I go up to my ribbon here we have got some options on the DESIGN tab
01:27called Group & Sort.
01:29If I turn that on, that will add this new window down to the bottom where I can
01:31start grouping these records together.
01:33I am going to press Add a group and I am going to choose to group them based
01:37off of their category.
01:39Now my records are sorted by category.
01:40I have got the Furniture category and then all of the departments under that and
01:43if I scroll down through my report, we'll see the home category here and then,
01:50all the departments under that.
01:51I'll go ahead and scroll back up.
01:53I can add additional groups down below that.
01:55I'll go ahead and add a new group here and this time I'll group on Department.
01:59Now I have got the Furniture category and the Bedroom department, and then all
02:03of the products that fall in to that department.
02:05Then I have got the dining department, still in the Furniture category and those products.
02:10I can scroll down to see all of the products and category groupings that we have.
02:15When I get to a new category, Home, the Home category has a bath, dining and
02:20entryways departments.
02:23Let's go ahead and scroll back up.
02:25Now underneath that, we can add sorting options.
02:28I can sort based off of the alphabetized product name or I can start to sort
02:32them based off of these values over here, the total numbers sold and the
02:35total dollar value.
02:36Maybe I want to see the popularity of some of my products;
02:39I am going to sort them by Total Sold.
02:42I'll add a sort and let's start by Total Sold.
02:46Now I can see that this is going from smallest to largest.
02:49I want to reverse that so that my most products is at the top.
02:52We'll sort it from largest to smallest, there.
02:55If I wanted to see it by overall dollar values, instead of popularity, I can
02:59sort it by Total Sold Dollars instead, here.
03:02Now it's sorting by dollar value and my most profitable products jump to the top of those list.
03:07I can also experiment with the ordering.
03:09Right now, we're looking at the categories and in the departments within each
03:12category, if I click on Department here, I can reorder these by pressing this up
03:17button here to move it to department up.
03:20Now I am grouping on Department first and looking at the Category second.
03:23So now my Departments are my home areas, my Bath department for instance and
03:28below that I have got the Home and Textiles, then I have got my Bedroom
03:33department and then in the Bedroom I have got Furniture and Textiles.
03:36So I have got a different organization to my records.
03:39Let's go ahead and save this report.
03:41I'll try and close it here.
03:43Access will tell me to save it and I'll say Yes and I'm going to call this
03:47Products Sold, that I'll append by Department, didn't know that they are sorted
03:52currently by the department.
03:54Setting up grouping and sorting options allows you to experiment with the
03:57presentation of your data, adding appropriate sorting to your data will
04:00bring the most important insights to the top of the list, so that they don't get overlooked.
Collapse this transcript
Creating calculated totals
00:00So far our products sold by Department Report has organized and grouped the
00:04records that were gathered by our products sold query.
00:07We can also add some statistical information about each group right inside of the report.
00:11This will give you some quick grand total figures that can help in understanding
00:15the data and making comparisons across departments.
00:17I am going to double-click on the Products Sold by Department report in order to
00:21open it up and take a look at where we are at.
00:24Right now our products are sorted by Department and then Category.
00:27Let's switch our view into Layout to add some summary statistics about each category.
00:31I am going to click on this Total Sold here and go up to the ribbon.
00:35Now if your Group & Sort window is still open from the previous movie, you can
00:39go ahead and close it.
00:40Then I am going to press Totals and Sum.
00:42That will add a new row down here that will sum up the total dollar value
00:47within this category.
00:48As I scroll down, I have got another category down here, the Textiles category
00:54and there is a sum total for that category.
00:57Then I have a sum total for the entire Department here.
01:02Now these might be a little bit small so we can go ahead and adjust their size
01:05by dragging them open a little bit more and I'll drag this one as well, to make
01:10them bigger so that there is more room to display that data.
01:13Now we'll do the same thing for this Total Number Sold.
01:16I'll click on one of the values, go up to Totals and say Sum.
01:19That will add the Sum total of the total number of products within this category.
01:24Let's do one more.
01:25I'll click on one of the products, go up to Totals.
01:28Now notice that since this isn't a numerical value, I can't add them together or
01:32find their average for instance.
01:33But I can count how many there are.
01:35I'll choose Count Records, that will add a count of how many records we have
01:40within this category.
01:41Now at any time, we can go back to Group & Sort and rearrange our
01:44Departments and Categories.
01:45For instance, if I don't need this granular level of detail, I can get rid of
01:49the category and just take a look at everything by department, to find the
01:52overall in the entire department.
01:54Let's go ahead and click on Category.
01:57I'll press the Close button over here to get rid of the Category group.
02:00Access will tell me that we are about to delete some calculated fields, but
02:04that's okay, go ahead and say Yes.
02:06Now our report is just sorting by the Department and I can see within this Bath
02:10department that our Bamboo Shower Curtain is by far our most profitable product.
02:16Let's make one more change here and then we'll take a look at what this report
02:19is looking like in Print Preview.
02:20I'm going to turn off our Group & Sort now and I am going to get rid of
02:25all these boxes again.
02:26I'll select in this box right up here and if you don't see it, go ahead and just
02:30select one of the fields and that should show up.
02:33Click on that box to select all of the cells within that report.
02:36And I am going to go to the FORMAT tab, Shape Outline and say Transparent to get
02:40rid of all the boxes around each cell.
02:42Then I'll go to the DESIGN tab and change my View to Print Preview.
02:46Now I can see that the Print Preview of my report, I have got the total number
02:50of products within each department, I have got the total number of sold in each
02:54department, and I have got the total dollar value for each department.
02:57Now you might notice that these numbers aren't formatted as dollar values.
03:00We can fix that up in layout view.
03:02I'll close Print Preview, click on one of those cells and go to the FORMAT tab
03:06and change it to a dollar value, there we go, that looks better.
03:09So there is our finished products sold report.
03:11I am going to go ahead and save it by pressing the Save icon on the Quick Access toolbar.
03:16By grouping the records together and calculating summary statistics across the
03:18groups, you enhance the value of the report by providing additional aggregation
03:22information at each change in category or department.
03:25This allows you to more easily compare data across departments and get a bigger
03:29picture of what's going on in the organization.
Collapse this transcript
Applying conditional formatting rules
00:00Conditional formatting rules will call attention to specific values that you
00:04would like to highlight in your report.
00:06Let's create a new report to analyze the No Obstacles company's customer spend levels.
00:10I have created a new query here, called Customer Spend and if I double-click on it to
00:15run it, we'll see those records.
00:16We have go the FirstName and LastName of our customers, the Region and State
00:20that they are from and then overall spend level that they have contributed to
00:23the company's bottom line.
00:24By switching to the Design View we can see how that was constructed.
00:27We have got four tables;
00:29Customers, Orders, States and Products.
00:31This is a totals query and down here this is how I am calculating the TotalSpend.
00:35I am taking the price of each product, multiplying it by the quantity that
00:39each person has ordered and then I am adding that up across all of the orders for each customer.
00:44Let's close this out and we'll create a report based off of this data.
00:47I'll go up to the CREATE tab and press the Report button, make sure that the
00:51query is still highlighted in the Navigation pane.
00:53Press Report to get a basic report.
00:55Now I am going to go ahead and adjust these field widths to shrink everything
00:59down on to one page.
01:00I'll make sure that this FirstName is highlighted and I'll reduce its Width and
01:04we'll do the same thing with some of these others, LastName, Region and State.
01:11Next, I am going to add an additional TotalSpend column here to the right side
01:15and I'll show you why I am going to do this in just a moment.
01:19But for now press, Add Existing Fields, that will show us all the fields from
01:23our query and I'll take total spend and I'll double-click on it again, to add a
01:27second duplicate column here.
01:28Now I can close my field list.
01:30Now let's say we want to highlight our top customers.
01:32I am going to click on this first TotalSpend column here and go up to the FORMAT
01:36tab and choose Conditional Formatting.
01:38Here we can create a new rule for how these values will be formatted.
01:41I am going to say New Rule, I am going to choose the Field Value is, here in the
01:47next box, we can choose how want to specify the value.
01:50We can specify a range between or not between.
01:54We can say equal to a specific value or not equal to a specific value.
01:57I can choose more than or less than a value or I can say greater than or equal
02:02to or less than or equal to.
02:04I am going to say greater than or equal to and in the next box over, I'll type 10,000.
02:08This will highlight all of our customers that have spent more than $10,000 with the company.
02:13We can adjust the formatting down here.
02:14I am going to change it to a bold font and I'll change the background color to
02:19this green color right here, Green 2.
02:21We'll get a preview of what that looks like over here.
02:24Go ahead and say OK and press Apply.
02:27And back here in our report, you will see that some of our values got highlighted.
02:31Let's go ahead and say OK.
02:32Now let's create a second conditional format for this second column.
02:36I'll click over here in this TotalSpend value, go up to Conditional Formatting
02:40and I'll say New Rule.
02:42This time I am going to choose Compare to other records.
02:45This will create a data bar whose width is determined by their overall spent.
02:49I am going to choose Show Bar only, that will remove the number from this field.
02:53I can choose a Bar color down here.
02:55I am going to choose this dark green color here.
02:58Here we'll determine how our lowest values and our highest values will be determined.
03:02We can either use the absolute values that appear in our data or we can specify
03:06our own low value and high value or low percent and high percent.
03:12I am going to leave it set to Lowest value and Highest value.
03:15Let's go ahead and say OK and then Apply, then we'll press OK to close the
03:20Conditional Formatting Rules Manager.
03:22You can see the data bars appear here in the background.
03:25In Access, the Data bars fade from the color we selected out to white.
03:28I find that this makes them a little bit difficult to read, but if we add a
03:32color in the background, for instance I'll go up to Shape Fill and choose this
03:35Dark Gray color right here, we get a better distinction of where that data bar
03:40ends and I can scroll through my values and see who's contributed the most and
03:44who's contributed the least.
03:46Now let's do one more conditional formatting.
03:48Here we have highlighted the cell where our customer spent more than $10,000.
03:53What if we wanted to highlight the entire row of that customer?
03:55Well, we can do that too.
03:57Let's go ahead and select these rows here, I'll start with the State, then I'll
04:00Shift+click on one of the customers' names.
04:03That will select all four columns.
04:04I'll go back up to Conditional Formatting.
04:07I'll say New Rule, and this time instead of choosing Field Value is here, I am
04:13going to choose Expression is.
04:15That will allow me to type in a formula.
04:17For the formula I am going to make reference to the original field which is TotalSpend.
04:22I'll do that with a square bracket, type TotalSpend with no space, closing
04:27square bracket and then we'll put in the same value, greater than 10,000.
04:32I'll set my conditional formatting to the same bold and the same green color.
04:38We'll say OK and then Apply and you will see that the entire row now gets the
04:44same formatting all the way across.
04:46Now let's get rid of those lines.
04:48I'll select all the cells here, go to Shape Outline and say Transparent and now
04:54we can scroll back up to the top, switch to the HOME tab and we'll take a look
04:59at it in Print Preview mode.
05:00Now we have got some conditional formatting rules that have been applied to our data.
05:04Whether you're looking to add impact or clarity, conditional formatting
05:06rules are easily applied to numerical data fields that you want to call
05:10special attention to.
05:11You can reference their value or using the expression, you can apply the
05:15formatting rule to cells based off of other data cells in the same record.
Collapse this transcript
Creating labels
00:00Access makes it really easy to generate a report that is perfect for printing
00:04out mailing label sheets.
00:05When you're doing your next mailing campaign or sending out billing notices, you
00:09can generate the labels you will need in no time.
00:12Just like our other reports, we'll first need to identify the people that we
00:15want mailing labels for.
00:16I'll create a quick query to gather what we need.
00:19I'll go to the CREATE tab and choose Query Design.
00:22Then I'll choose my Customers table and I'll close the Show Table window.
00:27I'll open this up and from my Customers table I need their FirstName,
00:30LastName, I don't need their Phone number, but I do need StreetAddress, City, State and Zip.
00:38To make this labels report really flexible, I am going to add a quick
00:42parameter query to our state, so that we can print labels for just the
00:45customers we need to target.
00:47Down underneath the State here, in the Criteria field, I'm going to type out
00:50a parameter request.
00:51I'll start with a square bracket and I'll say Enter State Abbreviation.
00:54I'll make sure to close that with a closing square bracket.
00:58Now when I run this query, it will ask me for the state that I am interested in.
01:02If I type ca and press Enter, it'll generate a list of just my
01:05California customers.
01:06Okay, let's go ahead and close this query and create our labels off of it. I'll close it.
01:12Access will ask me if I want to save it and I'll say Yes, and I'm going to call
01:17this Customer Mailing Label Query.
01:20Go ahead and say OK.
01:21Now we'll go up to the Create tab, make sure that our Customer Mailing Label
01:25Query is selected here in the Navigation pane and then choose this Labels button
01:29in the Reports group.
01:31That will start the Label Wizard.
01:33We can go through and select which type of labels we have.
01:36We could choose a manufacturer here, and there is a long list of different
01:40manufacturers of label sheets.
01:41I am going to keep it on Avery.
01:44We can choose the size of our label up here.
01:46We can look at the product number
01:48from the packaging or we can go by the dimensions of our label at how many there
01:52are across on the page.
01:54I am going to leave it on this first option here, the 1 1/2 x 2 1/2 with 3 across.
01:58If we needed to specify a custom label size, we can go into this Customize
02:02button and input our own parameters for the label sheets we have. I'll press Close.
02:06Go ahead and say Next and now Access asks us how we want to format our labels.
02:11We can choose a font and a font size here.
02:14We can choose whether we want a light font or a bold font or a medium font.
02:18I am going to keep it on Normal.
02:20We can change our text color, using the Build button we can choose any color we want.
02:24I'll leave it black and close this window.
02:26We can also choose to italicize or underline our values.
02:29I am going to leave both of those off.
02:32Go ahead and say Next.
02:33Now we get to build the text for our labels.
02:36I am going to click on this FirstName and press the Add button over here to add it over here.
02:41I'll press Space to add a space between those two and then move over to LastName.
02:46I'll press Enter on the keyboard to move down a line and then I'll enter in the
02:49StreetAddress by moving it over.
02:51I'll press Enter again, I'll do City, then I'll type a comma and a Space, the
02:55State and then a Space and then the Zipcode, to format my labels.
03:00We'll go ahead and say Next.
03:02Access asks us then how we want to sort our labels, let's do an alphabetized
03:06list based off of the Last Name.
03:08We'll add that over here, then go ahead and say next.
03:11Finally, we get to name our label report.
03:14I am just going to call it Customer Mailing Labels.
03:20Now we can see how the labels look when they will be printed.
03:23I'll press Finish, and the query runs.
03:25When the query runs, it asks me which State I am interested in.
03:28I am going to type in AZ this time, for Arizona and press OK and I get a label
03:33sheet of just my Arizona customers.
03:36If I close Print Preview and go back and close the Design View of that label,
03:41here, I can scroll down in my Navigation pane down to my reports.
03:45I'll find my Customer Mailing Labels and double-click on it.
03:49It again asks which state I am interested in, I'll type ca again, press OK and
03:54we get my labels for California.
03:56Now when it opens up this way, it opens up in layout view.
03:59I am going to go ahead and switch it here to Print Preview to see the
04:03three across layout.
04:04Now we just need to load the printer with our label sheets and press Print.
04:07Creating, mailing labels is really easy and when you combine the label report
04:11with some of the query tricks that we've seen, you can get exactly the labels
04:15you need without wasting pages on labels that you don't need.
Collapse this transcript
Adjusting print settings
00:00Report objects are specifically designed for the printed page, so it makes sense
00:04that at some point we all want to print them.
00:06We've been using the Print Preview mode to check out our layouts and confirm that
00:10things are looking the way that they should.
00:12But let's take a little deeper look at the options available in the
00:15Print Preview view.
00:16Let's go ahead and open up our Customer Spend report in Print Preview view.
00:20I can right-click on it and choose Print Preview from the pop-up list here.
00:23That will open up the form in Print Preview.
00:25I can click here to zoom in and scroll up and down on the report to see how it looks.
00:30Now up on the Ribbon we've got options here to send it directly to the printer.
00:35I can adjust its page Size including the type of paper that we're using and the Margins here.
00:40I can choose to print the data only, which will remove lots of the graphics and
00:44color options, I'll turn that back on.
00:46I can choose to change my paper from a Portrait orientation to a
00:50Landscape orientation.
00:51I can even use this button here to adjust columns if I wanted to print a
00:55multi-column report, go ahead and press Cancel.
00:57In this Page Setup button here we have finer control over some of these other options.
01:02For instance I can adjust the Margins to a specific value.
01:05If I wanted to go for instance 1 inch on the left and a quarter inch all the way
01:09around, I can do it that way.
01:11Go ahead and press OK to accept that change.
01:13But notice, when I go back into the Print Preview that my report reoriented
01:17itself, I might have to go back into the Design tools to accommodate to this change.
01:23Up here in the Ribbon again I can take a look at this report in other ways.
01:26I can take a look at it as a One Page view which we're doing right now or I can
01:30see a Two Page spread.
01:31If I wanted to I can see more pages, for instance I can go to Four, or Eight, or Twelve.
01:37Over here on the right we have ways that we can export this report.
01:39I can export it to an Excel file or even to a PDF file.
01:43I can even email it right here within Print Preview.
01:46If I press the Email button, it asks me what kind of file I want to export.
01:50I could choose for instance PDF and say OK.
01:54Access packages that up and launches Outlook, which is my email program, and
01:58attaches the file right there.
01:59So I can see it right here in the attachment field ready for me to address and send.
02:04I'll go ahead and close this email.
02:07Notice though while we're in Print Preview view that we don't have access to the
02:11other Ribbons on the tab.
02:12When I want to exit Print Preview, I'll press this Close Print Preview button
02:16over here on the far right.
02:17Now you can also get to the printing options from the FILE tab.
02:20If I go to FILE and down to Print, I have options to Quick Print, which will send
02:25the object right to the printer.
02:26I can press this Print here, which will bring up the standard Windows Print
02:30dialog box where I can choose a printer from the list, I can send a to Print to
02:34a File or I can change the number of copies here.
02:37Go ahead and say Cancel.
02:39So even though it's said that we're living in a digital age, all too often we
02:42still require printouts of our data to review and share with others.
02:46The Print Preview Ribbon allows you to set all of the parameters you need.
02:49Keep in mind though, that some of these settings will require you to go back to
02:53the designers in order to adjust your reports layout, in order for them to look correct when printed.
Collapse this transcript
10. Working with Macros
Creating macros
00:00Macro objects allow you to create a series of actions that you would like to automate.
00:04When a macro is triggered, Access runs through the steps and performs a task for you.
00:09In our Navigation pane on the left, I am going to scroll down to the very bottom.
00:13I have got a macro that I set up called Good Morning.
00:16This Good Morning macro will open up all the forms and reports that I want to
00:20see as soon as I start my day.
00:22I'll double-click on it to run it.
00:24And you will see that I get the Employee Phone List, the Training Department
00:28Employees form and the Products Sold by Department report, all right up on my
00:31screen without having to find them over here in the Navigation pane.
00:34Let's go ahead and close these three objects.
00:36There are lots of uses for macros in your Access database.
00:39To get started, let's recreate this Good Morning macro.
00:43First, I am going to delete the one that I have already.
00:46I'll right-click on it and say Delete.
00:48We'll go ahead and say Yes to confirm that I do want to delete that object.
00:52Now let's go to the CREATE tab and over here on the right in the Macros & Code
00:56group we'll find this big button for Macros.
00:58That will start a new macro in Design View.
01:01Here in the middle of the screen, I can choose which actions I want the macro to step through.
01:05If I scroll down the list, I can find an OpenForm macro.
01:10I'll choose that one.
01:13When I choose that action, the additional arguments and properties for that
01:16action show up on my screen.
01:18Here I can choose which form I want to open.
01:20I have got a dropdown list here that shows me all of the forms in my database.
01:25I can choose the Employee Phone List here.
01:28The next line down says View.
01:30This will allow me to change how I want to view my form.
01:33I can choose to open up in Form View, Design View, I can jump straight to Print
01:37Preview mode, I can view the Forms Datasheet or I can change it to Layout view.
01:42The PivotTable and PivotChart views have been depreciated and are no longer valid.
01:46Let's go ahead and leave it at Form view.
01:49Here, if I have established a premade filter, I can load that here, or if I
01:54know SQL, I can type in an SQL WHERE condition here.
01:58The Data mode will allow me to choose Add, Edit or Read Only.
02:02Add mode will open the form and display a new blank record at the end, ready for
02:07me to add a new record.
02:09Edit mode will show me the first record and allow me to view its data or edit it.
02:14And Read Only will load all the data but it will lock it so that I can't make any changes.
02:19I am going to leave it on Add mode, that will jump me a new record at the end.
02:24Finally, our options for Window mode are normal, Hidden, Icon or Dialogue, I am
02:29going to leave mine as a Normal window.
02:32Let's go ahead and add another action here.
02:34We'll open up another form, our Trading Department Employees form.
02:37I'll go down in the list, scroll down to OpenForm and here I'll fill in the form
02:44name that I want to open, Training Department Employees.
02:47One more action, this time we are going to open the report.
02:50I'll use the dropdown list and choose OpenReport.
02:55The report I want to open is Products Sold by Department.
03:01Now I have established three steps that my macro will run through.
03:04I can press the Run button here to test it out or I can press Signal Step mode
03:08here which will step through one at a time which is useful when you want to bug test.
03:13This button down here, Convert Macros to Visual Basic will take this macro and
03:17change it into Visual Basic programming language if you want to continue to edit
03:20it in that environment.
03:21This next group over Collapse & Expand will allow me to expand or collapse all
03:25of my actions which will make it easier to read what's going on.
03:29Now I can easily see the three steps, OpenForm (Employee Phone List),
03:33OpenForm (Training Department Employees) and then OpenReport (Products Sold by Department).
03:39In the Show/Hide group here we have this Action Catalog toggle.
03:42If I turn that off, and then on, you will see that the Action Catalog is this
03:46window over here on the right.
03:47It has a listing of all of the actions that are available in the Macro Editor.
03:51I can expand the groups here to see the various actions and if I want to get
03:55some information about an action, I can just hover over and take a look at the tool tip.
04:00Finally, the Show All Actions button here will turn on some additional actions
04:04that will show up with this icon here.
04:06The Show All Actions button will also give you access to actions that
04:10are considered unsafe.
04:11These are the actions that get blocked by database that hasn't yet been trusted.
04:15Okay, let's go ahead and save our macro and we'll try running it.
04:18I'll press the save icon here and give it the name Good Morning.
04:23Go ahead and say OK and now, I can press the Run button to see if it works and
04:27sure enough, I get my three objects.
04:30Let's go ahead and close them down and I'll also close the Action Catalog by
04:34clicking this x here and I'll close my macro by clicking this x here.
04:39Now again, it shows up in my Navigation pane down in the bottom.
04:42I can double-click on it to run and again, I'll close those three objects.
04:46If I want to get back and edit it again, I need to right-click on it and then go
04:50to Design View here, that will open it back up in the editor.
04:54So adding macros to your database can help automate common and repetitive tasks.
04:58Explore the action catalog for various components that you can apply to your own work.
Collapse this transcript
Embedding macros into buttons
00:00Macros can activate all kinds of abilities in your database, and the most common
00:04way to trigger them is by pressing a button.
00:07Earlier we saw how we can use the Button Wizard in a form to choose from a
00:11predefined list of actions.
00:13Using the full Macro Designer we can get much more control over the functions
00:16that our buttons perform.
00:18Let's add some buttons to enhance the functionality of one of our Report objects.
00:22I am going to scroll down on my Navigation pane and find the Products Sold
00:25by Department Report;
00:26I am going to right-click on it and open it into Layout View.
00:29Now right now this report is showing all of our Products listed by Department
00:35and then within each Department we have the Category breakdowns.
00:38Let's add some buttons here right on our report to be able to filter out to
00:42specific categories that we might be interested in reviewing.
00:44I am going to click up here on the title bar here where it says Products Sold
00:48and then I am going to go to the ARRANGE tab and choose to Insert a row below,
00:53this will be where we'll put our buttons.
00:55Now when we do that the layout grid adds a new row down below.
00:58I can click on it to see where it is.
01:01It highlights cells when you've selected them with this orange border, but when
01:04they're not selected it has a gray dashed border, it's really hard to see.
01:08so let me change the background color here so we can see it on the screen.
01:11I'll click back here to select this gray bar in the back, I'll go up to the
01:14FORMAT tab, go to Shape Fill and I'll change it to white, now we can see
01:19the gray borders here.
01:20Now I need to create the areas where I want to place my buttons.
01:23I am going to click on this large cell here, go to the ARRANGE tab and I am
01:27going to split it horizontally, that will chop it into two pieces.
01:31Now I'm going to need to chop up these two pieces into two more pieces.
01:34So I'll select this first one and split that one and select this one over
01:37here and split that.
01:39Now I've got some areas for my buttons.
01:41I have one here, here, here, here and here.
01:45Now I am going to go back to the DESIGN tab and in this Controls group I am
01:50going to grab a button object.
01:52I'll grab it here and then I'll go down to this first cell and I'll click to add a button.
01:56Now I want to double-click on it to edit its text.
01:59I'll double-click again to highlight it and this one is going to say All.
02:02This will be the button that will return us to an unfiltered state.
02:05If we need to we can resize the button by clicking on the bottom and dragging
02:08down just a little bit so we can see the whole thing.
02:11Okay, let's add in some more buttons.
02:13We'll click another button object and click into the next cell, then I'll
02:16double-click and this one is going to filter to adjust our Textile category,
02:21I'll type in Textiles.
02:22All right, let's go ahead and deselect it and select the next cell.
02:26I'll add another button here, I'll double-click and this one is going to filter
02:30just our Home category.
02:33Okay we've got two more to do, I'll click on this one, I'll add a button
02:37there, double-click to edit the text and this one is going to be our Furniture category.
02:45And finally I'll click in the next cell, choose a button and then add it here,
02:50double-click and this will be our Lighting category.
02:54So now I have all of my buttons.
02:56Now I need to tell these buttons what they're going to do when we click on them.
03:00To do that, I'll open up the Property Sheet.
03:02In the Property Sheet we have a tab for Events.
03:05The Events tab controls all of the ways that we can control various actions with our buttons.
03:09I am going to choose the Textiles button first and you'll notice the Property
03:13Sheet changed here, now it says Command60 which is the name of this button.
03:17And in the On Click Event, this is what happens when you click on the button,
03:21we're going to create an embedded macro.
03:23Rather than create a standalone macro that takes up space over on an
03:26Navigation pane on the left, we can create a macro whose code is saved
03:30directly inside of this button object.
03:32I'll click on the Build button over here on the right.
03:35Access then needs to know how we want to construct the macro, I'll choose to
03:39use the Macro Builder.
03:40Our other options are the Expression Builder or Code Builder which will allow us
03:44to enter Visual Basic code.
03:45Go ahead and select Macro Builder and say OK.
03:48that will take us into Macro editing session and I can see that I am inside of
03:53that Command button in the On Click event here, on the tab.
03:56Now the action that I want to choose is an ApplyFilter action.
03:59I'll scroll down the list and find it here.
04:02The ApplyFilter action will filter my data that's being fed into the report.
04:06I don't have a pre-made filter here so I need to enter in an SQL filter in
04:10this Where Condition.
04:11But we have this Build button way over here on the right, I'll click that and
04:15that will bring us the Expression Builder.
04:17You might remember the Expression Builder;
04:19we take a look at this in the chapter on queries.
04:23So now I need to construct my filtering criteria.
04:26I can go into my database objects here, into my Tables here, into my Products
04:32table I'll double-click on Category to add that to the syntax and now we just
04:37need to say what I want the category to equal when I press that button.
04:41That was the textiles button so the ( Product)!(Category) is going to equal (=)
04:44and then in quotation mark "Textiles".
04:47Go ahead and say OK, that is our filtering criteria.
04:51I can go ahead and close the Action and save any changes and now that button is
04:57done, you can see the On Click Event has changed to the (Embedded Macro), let's
05:01do one for the Home.
05:02I'll click here on the Home button, on the On Click event in the Property
05:06Sheet I'll click Build;
05:08I'll open up the Macro Builder and say OK.
05:11Once again, we're going to choose apply filter.
05:13This time I am just going to type App and it jumps right to ApplyFilter.
05:18I'll press Enter, for the where condition I'll go to my Builder, I'll dig into
05:24my database object here, into Tables, my Products Table and I'll double-click
05:30on the Category Expression Category here, = "Home", go ahead and say OK and
05:40we'll close the Macro.
05:41Save the changes and there is those two.
05:44I am not going to do Furniture and Lighting, I think you can see the pattern
05:48here, but I do want to do the All one, that one that's slightly different.
05:52Here we're going to go to the On Click event, Build;
05:54Macro Builder once again, we'll say OK. We're going to use the same
05:59ApplyFilter, the Where Condition here and then once again click on the Build
06:04button on the far right.
06:05I'll go into my database, choose from the Tables and the Products table and
06:11we'll get the Category field.
06:12I am going to say equals (=) here.
06:14And then what I want the Category to be equals to is True.
06:19I am not saying here that I want the Category to be the name True, but what I'm
06:23saying since I am not wrapping it in quotation marks, is that there is a
06:27category of some sort.
06:28If there is a category then I want to display it, this will show me all of my categories.
06:33Go ahead and say OK, I'll close the Macro Editor, Save the changes again and
06:38there is my first three buttons, let's go ahead and test them out.
06:42I'll switch my view into Report View by clicking the top half of the View button
06:46and I am going to click on the Textiles button.
06:48And you can see that my categories have filtered to just the Textiles.
06:52I'll click on Home and you'll see now I am looking at just my Home categories
06:56within each department.
06:57I'll click on the All button to return to a unfiltered state.
07:01Now the nice thing about this report is that if you remember when we constructed it,
07:04is that we created some calculated statistics down here at the bottom.
07:08Right now what I'm looking at all products, I can see that I've got eight
07:11products in the Bath department here, there is the number 8.
07:15The total number of sold was the 612 and this is the total dollar value that
07:19they've contributed.
07:20If I filter it by clicking on the Home button for instance, you can see now that
07:24these statistical lines update.
07:25Now I've got three categories in the Bath department, for a total number of sold
07:29of 69 and there is their value.
07:31If I switch to Textiles, you can see there they update again.
07:35So rather than clutter up our Navigation pane with lots of one-time use macro
07:39objects, we can often create embedded macros that are attached directly to the
07:43button that activates them.
07:44And using a macro to filter our data on the fly makes our Reports and Forms even more flexible.
Collapse this transcript
Attaching data macros to tables
00:00Data macros are macro events that are triggered when something changes in a data table.
00:05They're most commonly used to essentially watch what gets entered into the table and
00:08then respond to that entry event by creating a log, noting the change that happened
00:13and recording the time and date when the change was made.
00:16Let's create a simple logging system to keep track of the changes that are made to the
00:19No Obstacle Company's Employee JobRatings.
00:22First, let's take a look at the existing Employees table.
00:24I'll find it in the Navigation pane and I'll double-click to open it.
00:28Now if I scroll over to the right, you can see that each employee has a JobRating.
00:33Right now it's a scale of 1 to 5.
00:36What I want to do is set up a system that logs changes to this rating.
00:39So if somebody's JobRating changes from a 5 to a 4, for example, I want to create
00:44a record in a new table noting that change.
00:47I want to know when the change happened, what the original number was, and what the new number is.
00:52Let's go ahead and set that system up.
00:54I'll go ahead and create a new table to hold the log by going to the CREATE tab and choosing Table Design.
01:01The first field in our table is going to be the ID for this table, I'll call it LogID.
01:04I am going to choose a Data Type here of AutoNumber, this will be our primary key field,
01:11so I'll press a Primary Key button here on the Ribbon.
01:14The next field will be the foreign key, this is how we will link back to the Employees
01:18table and we'll do that based off of the EmployeeID.
01:21I'll go to Data Type and choose Number.
01:26The next field here will hold the old job rating.
01:29This is the rating as it is before the change was made.
01:31I'll call it OldRating with a no space and Data Type here will be a Number.
01:37Now I want a cell for the new rating, I'll call it NewRating with no space and again
01:41the Data Type will be Number. And finally, I want a date stamp here.
01:45I'll type DateStamp for the Field Name with no space and the Data Type will be a Date/Time Data Type.
01:52So there is our table, let's go ahead and save it using the Save icon on the Quick Access
01:56toolbar and I'll change its name to EmployeeRatingLog and go ahead and say OK,
02:02and finally, we'll switch into Datasheet view.
02:05We don't have any records here so we are going to wait and we'll go back into our
02:08Employees table and we'll finish up by adding a data macro.
02:12I can add a data macro by going to the TABLE tab here.
02:16The TABLE tab has all of the events that will trigger macros.
02:19I have Before events, these are things that will trigger Before a record is updated and
02:24I have After events, the After Events will trigger after a change is made.
02:28You'll notice if you hover your mouse over the After Update button, you'll get
02:32a tool tip telling you how it works.
02:34This says that it creates logic that runs after an existing record has been changed
02:37and the last paragraph is important, it says use Old.Field Name to inspect the value
02:42of a field before the record was changed.
02:45We're going to need to know that syntax here in just a moment, Old.Field Name to inspect the value before.
02:50Okay, so let's go back and press this After Update button and I'm going to start with our Macro.
02:57Now the first thing we want to know is that the After Update will fire any time any changes
03:02are made to an employee, not necessarily changes that are made to their JobRating.
03:06So the first thing I want to do is know if a change occurred to the JobRating field.
03:10I am going to insert an If block by double- clicking it on the Action Catalog over here on the right.
03:16If the Action Catalog isn't Open, you can toggle it open using this button here on the Ribbon.
03:21That will add this If statement here.
03:23So first I need to test if the new JobRating is the same as the old JobRating.
03:28If it's the same, then that means that no changes were made to JobRating, the change
03:32was made somewhere else in the record.
03:33So I am going to type in a reference to the JobRating field by using a square bracket
03:39and typing JobRating and as you can see as soon as I start typing, Access suggests the values that are valid.
03:44I'll go ahead and press Tab to accept this JobRating value right down here. That will fill it in for me.
03:50Now I can say JobRating= and this is where we remember that the old JobRating is available if we type old.
03:58and then the Field Name again is JobRating. I can also select it from the list here.
04:06So if JobRating=old.JobRating then we'll run this action here.
04:11The action we want to do is just StopMacro.
04:15That way if no changes were made, the macro will end.
04:18If a change was made, however, we'll go down here, we'll add an Add Else.
04:22If a change was made, we want to create a new record in that EmployeeRatingLog.
04:28We'll choose CreateRecord, Create a Record In, I can choose which table I want to create the record in. EmployeeRatingLog.
04:38Now we'll set up the actions to fill in the fields.
04:41From the list we'll choose SetField, the field that we want to set is the EmployeeID and
04:50the Value is going to be the value of the Employees table EmployeeID.
04:56So it reads Employees.EmployeeID.
05:07So set the Field, EmployeeID to whatever value the EmployeeID is of the record that's changing.
05:12We'll add another SetField here.
05:15SetField, this time we are going to set the value of the old rating field in our EmployeeRatingLog.
05:22And down here the value of that is going to be whatever the old JobRating was, Old.JobRating.
05:38We've got another field to add here, SetField.
05:43We'll set the new rating field, and down here I'll change it to the reference to the JobRating in the Employees table.
05:54And finally we need to at add our DateStamp, so we'll add one more SetField, the name of
06:00this one is going to be the DateStamp field, that's in our EmployeeRatingLog and the Value
06:06for this is going to be now().
06:11That's code to just pull the today's Date/ Time and apply it to the DateStamp field.
06:15Now just looking through here I notice that I had a typo here, I've got this Name set
06:18to Old and that should have been OldRating is the actually name of the Field in the EmployeeRatingLog.
06:23Okay, so let's walk through this step by step.
06:26I'm going to Collapse the Actions here to scrunch everything down over the screen and
06:31I'll go here and Collapse again, okay.
06:36So let me read through this, it says if the JobRating is the same as the old JobRating,
06:41then nothing has changed and we are going to StopMacro.
06:43Otherwise, we are going to Create a new Record in the EmployeeRatingLog.
06:49The fields in that record are going to get set to these values here.
06:52We'll set the field EmployeeID to the EmployeeID from the record that's changing.
06:57We're going to set the field OldRating to the value of the OldRating before we create the change.
07:02We are going to set the field NewRating to the newest rating and we are going to set
07:06the field DateStamp to whatever the current date and time is.
07:10Let's go ahead and close our Action and we'll save our changes to it and that will complete the process.
07:16So now it's just a matter of going through and checking.
07:18I am going to go to this first record here, the JobRating that I previously changed from
07:22a 5 to a 4 and I'll highlight it, I'll type in a 5, and then I'll click off of this record
07:28to apply that change to the table.
07:30Now let's go back to our EmployeeRatingLog, which is still open in the background and take a look.
07:35It doesn't show up automatically but if I press the Refresh button, you should get a
07:38new line noting that EmployeeID 1 had an OldRating of 4, a NewRating of 5, and this DateStamp
07:45field here will show the exact time and date down to the second that I made that change.
07:50If I go back to the Employees table and make another change, I'll just go down here and
07:54change this 5 to a 4 and click off of it, go back to my RatingLog and refresh the data
08:01and you can see that I changed Employee ID 12 from the OldRating of 5 to 4 at this time and date.
08:08Now because this is attached to the Table, any changes to the table will affect the log.
08:13But I can go ahead and close the table and go into our form that we created earlier,
08:18this Training Department Employees, I'll open that up, and this JobRating here, we will
08:23convert it to an Option Group.
08:25But any changes that we have here are being saved back to the table, so if I change this
08:30Employee here, from Needs Improvement to Good and then click this pencil icon to save the
08:37changes to the table, go back to my RatingLog, refresh the data, you'll see that I changed
08:43employee 670, the OldRating was 1, it's now 4 and that's exactly when I did it.
08:50Creating an automatic change log system is a great way to integrate DataMacros into your Database.
08:55By keeping a running timestamp record, you can not only find the current value for a
08:59field, but you can see the entire historical record of how that field's value has fluctuated over time.
Collapse this transcript
Launching macros at startup
00:00It might be useful to have a macro run immediately when the database is first opened.
00:05We could do that by giving one of our macro objects a very special name.
00:09Let's create a macro that will run at startup.
00:11I'll go to the Create tab and create a new Macro in Design View here.
00:15First thing I want to do is have a little message box pop up welcoming us to the
00:19No Obstacles Database.
00:20I'll type in M E and that will jump me to the MessageBox action.
00:25I'll press Enter and here we can fill in the details.
00:28The message is going to be Welcome to the No Obstacles Database.
00:31If you have any questions, please ask Adam.
00:35We could choose whether we want the MessageBox to Beep or not, I am going
00:38to change that to No.
00:39We can have a Type here, it can either be a None,
00:42it can be a Critical message, a warning or an Informational message.
00:46This will define what icon displays to the left of it.
00:49I am going to leave it as None.
00:51And we can have a Title here that will appear at the top of the MessageBox.
00:55I am going to put in the No Obstacles tagline, Defy Obstacles, Live Boldly.
00:59So now that our MessageBox is complete, the next action I want to do is get our
01:03database started by opening up our Navigation Form.
01:05Here I'll choose OpenForm from the list, the FormName I'll choose that from the list.
01:11It's going to be our Navigation Form.
01:14We can choose our View mode here.
01:16the options again are Form view, Design view, Print Preview or Layout.
01:20I am going to switch to Form view so we can get to work.
01:23We don't need to apply any filtering and I'll leave these other settings the same.
01:27So there is our Macro, now the magic here is that we are going to call this with
01:30a name that's very special that will tell Access to run this Macro every time
01:34the database starts up.
01:35I'll go ahead and press the Save icon up here and the name I want is autoexec
01:40a-u-t-o-e-x-e-c, which is short for Auto Execute.
01:45Go ahead and say OK and that creates our Auto Execute Macro.
01:49I can test it here by pressing the Run button and we'll get our MessageBox here
01:52that's welcoming me to the database, I'll say OK and then my Navigation Form
01:57opens up ready to get started for the day.
01:59Lets go ahead and close that down and I'll close the Action Catalog and
02:03close the macro here.
02:05Now let's test it out to see if it runs at start up.
02:07I'll go to the File tab and say Close.
02:11Then I'll go back to the File tab, I'll say Open and from my Recent's list,
02:16I'll choose the current exercise file here.
02:18That will start up. When the Database starts the macro runs.
02:22Here is my text box here telling me that it's welcoming me to the database and I
02:26ask myself if I have questions.
02:28Go ahead and say OK and there is my Navigation Form so I can get started with my work.
02:33The Auto Execute Macro is a great little hidden feature that can help you get
02:37your users to where they need to go, right when they open up the database.
02:41But if you ever need to bypass the autoexec macro, for instance I'll close this
02:45out and File>Close my database, I can do that by going to the File button, Open
02:52and then holding down the Shift key on your keyboard when you open up the file.
02:55You'll notice now that that will bypass the start up option and that the
03:00Autoexec Macro doesn't run.
Collapse this transcript
11. Integrating Access with the Office Suite
Exporting tables to Excel
00:00There will be times when you want to move your data out of Access in order to
00:03perform some further analysis with the tools available in Excel, such as
00:07charting or pivot tables.
00:09In order to do that we need export our data to an Excel file.
00:13First, we need to select the object we want to export.
00:16I'll choose my Customers-MidwestRegion query here.
00:19Then I'll go up to the EXTERNAL DATA tab and take a look at our Export group.
00:24Here, we have options to export to an Excel file, we can also export to a Text
00:28File, an XML file, a PDF or XPS file or we can export to an Email, an Access
00:34database a Word Mail Merge and under More we have some additional options.
00:40Let's go ahead and choose the Excel button here in the Export group.
00:43Make sure you are not pressing the Excel button over here that's in the Import group.
00:48When I press the button, the Export wizard starts.
00:51First I need to tell it where I want to save it.
00:53I'll click the Browse button over here and I'll browse out to my Exercise folder,
00:57which is on my Desktop
00:59in the exercise files folder, in the Ch 11 folder. I'll go ahead and give it a name here.
01:06I can also choose which type of file I want.
01:08I can choose an Excel Binary Workbook, a standard Excel Workbook, a Microsoft
01:13Excel 95 Workbook or an Excel 97 to 2003 Workbook file.
01:17I am going to choose the standard and current version one hear.
01:21Go ahead and say Save and that will return us back to the wizard.
01:24Here again we can choose our file to confirm and we have a couple of additional
01:28options at the bottom.
01:30We can choose to Export our data with formatting and layout.
01:33I generally turn this one on, not necessarily because I want the formatting, but
01:36because it unlocks the other option below which I find really handy to open the
01:40file after the Export is run, go ahead and select that one as well.
01:44Now if you have previously made a selection in your Data Source, you can also
01:47export only the selected records.
01:50Go ahead and press OK and the Export will run.
01:53Excel will go ahead and open up and display our data.
01:56I am going to go ahead and close Excel and that will return us back to Access.
02:02Now when I come back to Access the wizard has changed, now it says Save Export Steps.
02:07I can choose to Save those export steps if I want to re-run the export at a future point.
02:11I am going to go ahead and say Save export.
02:14We can give it a name here, Export-Customers-MidwestRegion, that name is fine for me.
02:19We can also give it a Description, something like export monthly on the 15th of the month.
02:25We can also choose to Create an Outlook Task.
02:28This will create a reminder for you in Outlook.
02:31Go ahead and say Save Export.
02:33Now when you want to redo the Export, you can just go up to your Save Exports here,
02:37choose the one you want and press Run.
02:41Access will reexport the file and if it's already there it will overwrite the
02:45existing one so we can say Yes and the Export runs and we have our current
02:51snapshot now saved as an Excel file.
02:53Exporting your data to Excel, or indeed any number of the available export types,
02:58is a straightforward procedure.
03:00And as if it weren't easy enough, you can even save the steps and rerun them
03:04next time with just a single-click using the Save Export Options.
Collapse this transcript
Emailing with macros
00:00Not a day goes by that I don't have to email several files off to various people.
00:04If you're like me, I'm sure you find yourself constantly exporting files,
00:08saving them to your hard drive, opening your email program, then attaching the
00:12file and sending it off.
00:13That's a lot of work for something we do so regularly.
00:16I would much rather press one button and be done with it.
00:19Well using what we've seen about macros, we can do just that and it's a
00:22fantastic time saver.
00:24I'm going to open up this Customer Spend report that my boss has decided that
00:28she would like emailed to her once a week.
00:31Rather than go to the process of exporting it to a PDF, then manually creating
00:34a new email and attaching it, we can simply use the built-in Export to Email option.
00:39You can find it on the EXTERNAL DATA tab here and then the Email button here.
00:44I'll press the button and Access asks me what kind of object I'd like to send,
00:48I'll choose PDF and press OK.
00:51Access packages up the email as a PDF and attaches it to an email right
00:55inside of Outlook for me.
00:57Now I can just address it and send it off.
00:59But believe it or not that was actually the hard way of doing that.
01:03I'm going to close the email without sending it and return to Access.
01:07In my case, I know I always want to send this report as a PDF, and I also always
01:11know who it's going to.
01:13I can save even more steps by creating a simple macro.
01:15I am going to open up this report in Design View by going to the HOME tab and
01:20changing my View to Design View here.
01:21I am going to add a button to the top of my report here.
01:25Up in the DESIGN tab, in the Controls group;
01:27find the button object which is this one right here with the Xs in it.
01:31Go ahead and click that, and then down here in the header, click once to add a button.
01:36Now I will open up the Property Sheet to define what this button is going to
01:40do when I click on it.
01:41Go ahead and open up the Property Sheet here, then go to the Event tab.
01:45I am going to go to the On Click event here and on the far right press the
01:49Build button over here.
01:51Access asks us how we want to construct our code.
01:54I am going to use the Macro Builder and choose OK.
01:57Now we are going to create an embedded macro that's attached to that button,
02:00that's on our report.
02:02I am going to say my Action is going to be EMailDatabaseObject.
02:05I'll just write in the word EMail and Access jumps right to that action.
02:10I'll press Enter to accept that and all of the properties show up for this action.
02:15Now I can tell it what I want to email.
02:17The Object Type is a report, so I'll type Report, the Object Name, that's our
02:22Customer Spend report, so I'll type in Customer Spend.
02:26Output Format, here I can specify that I always want it to be a PDF, that way it
02:32won't ask me every single time.
02:34On the To line I will specify who I want it to go to;
02:37jleonard@no-obstacles-inc.com.
02:41I can specify Copy lines or Blind Copy lines.
02:43I can even specify a Subject;
02:45Here is the Customer Spend report.
02:50On the next line down, I can enter the Message Text that I want to say;
02:54Please find the pdf file attached.
02:59Finally we have a chance to edit the message here in Outlook.
03:02I am going to leave that set to Yes so that I can have a chance to review the
03:07email before sending it off.
03:07Okay, we're done with our macro. We can go up to the Quick Access toolbar and
03:12press Save to save it and then close our macro here.
03:15Now we're back into Design View of our report, I'll switch my View to Report View.
03:20Now when I'm viewing my report, I can press this button here, Access will
03:23package up the email as a PDF, address it, attach it, put in the Subject, put in
03:29the body text, and now all I have to do is press Send.
03:32Now I can hear some of you saying, but Adam I don't really want an ugly button
03:35at the top of my beautifully crafted report.
03:37Well, if we switch back into Print Preview mode here by closing Outlook and
03:41changing our View to Print Preview, you'll notice that the button doesn't even
03:45show up in Print Preview mode.
03:47So using just a little ingenuity and problem-solving skills, we were able
03:51to boil down what was once a time-consuming and repetitive task to just a few simple clicks.
03:56You can either use the built-in Export Email option or with just a little more
04:00upfront setup, with a one click macro button.
Collapse this transcript
Linking to data in an Outlook database
00:00You may not have realized it, but the Microsoft Office suite contains another
00:04great database program.
00:06Outlook maintains tables in its own database of all of your emails, contacts,
00:10tasks and calendar events.
00:13We can dig into that database from inside Access in order to easily bring that
00:16information in from Outlook.
00:18To get your Outlook database you go up to the EXTERNAL DATA tab and choose in
00:22the More group, Outlook folder.
00:25This will start the External Data wizard.
00:27We can choose to import the data into a new table, Append a copy of the records
00:31to an existing table or Link to the data source by creating a linked table.
00:36By creating a linked table we allow access to keep up to date with what's
00:40happening in Outlook.
00:41When we add a new calendar appointment or a task, Access will immediately see
00:45those changes when we've linked the tables together.
00:47I am going to choose this Link option and press OK.
00:51Now we can see inside of the Outlook database file.
00:53I am going to go into the user account here and choose Inbox and press Next.
01:00We can go ahead and give it a name;
01:01this is how we want it to appear here on our Navigation pane, I will choose
01:05Inbox is fine, go ahead and say Finish.
01:09Access links to the tables and we can say OK to take a look inside of our database.
01:14I'll scroll up to get back to my Tables group and down here at the bottom I've
01:18got the Inbox table.
01:19You can see it's a linked to Outlook table with this icon.
01:22If I double-click on it to open it, you can see the contents of the inbox,
01:26including Priority status, the Subject of each email and who they are from as
01:31well as any message text or body text.
01:34Once your tables are imported into Access, you can view them right here and make use of them.
01:39You can also use them as you would any other table.
01:41You can establish relationships to other tables based off of a common field or
01:45create queries or reports off of them.
01:46For example, you could generate a report to show the productivity of each month
01:51as measured by the number of completed tasks, or you might want to use the
01:55addresses in your contacts list to setup mailing labels.
01:58How about a query that finds the number of emails that mention a specific
02:01product, sort it by the region the customer is from?
02:05The possibilities are endless.
02:07If you're an Outlook user you probably have lots of data already stored in
02:10your Outlook database.
02:11Bringing it into Access can help free it up so that you can use it for rich,
02:15in-depth analysis or reporting.
Collapse this transcript
Setting up labels and mail-merge documents in Word
00:00Using the data stored in your Access database, you can easily populate Mail
00:04Merge documents in Word to create personalized letters, envelopes and other
00:08types of correspondence.
00:10We are going to create a letter that is tailored to each of our 200 customers.
00:14To start, I am going to scroll up in my Navigation pane and choose the Customers table.
00:18Then I am going to go to the EXTERNAL DATA tab and choose Word Merge here on the far right.
00:24When I do that, the Microsoft Word Mail Merge Wizard opens.
00:27It asks, what do I want the wizard to do?
00:30I can either link to your data to an existing Microsoft Word document or we can
00:34start a brand-new document by clicking this button here.
00:37I am going to start a new letter, so I will go ahead and say OK.
00:40When I do that, Word starts up, I can go ahead and go open it here in the
00:44background and I am going to maximize Word, and we can see that the Mail
00:49Merge Wizard has started over here on the panel on the right, we have some
00:52options here and I can also start writing out my letter by inserting Merge
00:56Fields from this button here.
00:58So I am going to start my letter with the address for my customers.
01:01I am going to insert the field FirstName and then type a space and then
01:05insert the field LastName.
01:07I am going to press Enter to go down to the next line and then I will insert
01:10the StreetAddress line.
01:12I will press Enter to go down a line.
01:14Then I'll enter in the City comma space, choose the State and space
01:22and choose Zipcode.
01:24Now I will press Enter a few times and I will type out the word Dear, put a
01:28space and I will go back up one more time and select FirstName and press comma.
01:34For the body of my letter, I have got a text file saved in the Exercise folder.
01:38So let me go grab that.
01:39I will go back out to Windows Explorer and I am going to choose the
01:43MailMerge text document.
01:44I will select it and press Ctrl+A on my keyboard to select all of the text and
01:49then Ctrl+C to copy it.
01:51I can go ahead and close Notepad and I will return back to Word.
01:55Now back in my MailMerge, I am going to press Enter a few times, and I will
01:59press Ctrl+V on my keyboard to paste in the text.
02:02We can go ahead and modify our spacing however we would like and that's
02:06looking pretty good.
02:07So let's go ahead and view the results.
02:08I can scroll up to the top.
02:10In the Preview Results group, I will press this Preview Results button.
02:14Now the letter is being populated with data from the database.
02:17I can scroll through the various records to see how it looks with
02:20different individuals.
02:22Now we have got a customized letter for each one of our customers, ready to be mailed.
02:27Pairing your Access database with powerful capabilities of Word's Mail Merge
02:30feature is a great way to get more out of the data you've been diligently
02:34collecting and organizing.
02:35For more information on using Microsoft Word, please take a look at Word 2013
02:39Essential Training here at lynda.com.
Collapse this transcript
12. Maintaining the Database
Organizing the Navigation pane with custom groups
00:00Now that our database is filling up with objects, you might want to consider
00:03reorganizing your Navigation pane, so that your objects are grouped by task
00:07rather than by object type.
00:09We can create custom groups, so that all of the objects that go together will
00:13appear next to each other, regardless of whether they are forms, queries,
00:16tables, reports, or macros.
00:18We will start by changing the View mode on the Navigation pane.
00:21Click on the down arrow here and change it to Tables and Related Views.
00:25Now Access groups all of our objects based off of their relation to each table.
00:29You will notice that we get duplicates of each object such as this
00:32EmployeePhone Crosstab is related to both the EmployeePhone table and if I
00:36scroll down, the Employees - Table.
00:40Just like sorting by object type, we can use the up arrows on these categories
00:43here to collapse each group.
00:46If you would like to have full control over the groupings of your objects, go
00:50back up here to the top and change it to Custom group.
00:53I will go ahead and scroll up to the top of my Navigation pane and you will
00:57see that I have two groups now, one called Custom Group 1 and another called
01:01Unassigned Objects.
01:02We can group objects together based off of the relationship to each other or a particular task.
01:07To add objects to a group, simply drag and drop.
01:10For instance, I am going to make a group that's all about our customers.
01:14I am going to take the Customer table and drag and drop it up into Custom Group 1 up here.
01:18Now I can right-click on it and choose Rename and I am going to rename the
01:22Custom Group to Customers.
01:24I will make sure it's expanded.
01:26Now I can drag other objects into it, for instance CustomerCreditCards.
01:30I will click and drag that up as well.
01:32I can scroll down through my database and I will find some other things that
01:35relate to the customers, for instance, this Customers Mailing Label report.
01:38I will click and drag it up to the top and drop it in the list.
01:43Let me scroll back down.
01:45We have got some queries I want to add as well.
01:48Rather than drag and drop, I can right-click on them, for instance this Customer
01:52Spend query, I will right-click on it and choose Add to group>Customers.
01:57Now let's add a different group.
01:58I am going to right-click on the Products table.
02:00I will go Add to group and this time I will choose New Group.
02:05That adds a new custom group at the top of the Navigation pane.
02:08Once again, I will rename this one, right-click, Rename and I will change this to Products.
02:14Now I can add things to that as well.
02:16I will right-click on Products - Furniture>Add to group>Products, products -
02:21Textile tables as well, Add to group>Products.
02:24We can scroll down.
02:25How about the Products Sold query?
02:27I will right-click on it, Add to group>Products.
02:31I can go through my entire database and organize everything based off the common task.
02:35If you would like later to delete your Custom groups, just right-click on the
02:39heading and go to Delete.
02:41Notice that all of the products then get put back into this Unassigned Objects
02:44group here at the bottom.
02:46Having multiple organization scenes set up for your objects in your database
02:49makes it easy to manage all the components and quickly find the ones you want to work with.
02:54Once you have set up your custom groups, you can switch back and forth to the
02:58other grouping options as needed.
Collapse this transcript
Compacting and repairing the database
00:00When working with you Database files, Access keeps track of changes that you are
00:04making in the background, and when you delete an object, or lots of records,
00:08Access doesn't actually give you that disk space back right away.
00:11If you notice your Database is running slower, or you would like to squeeze
00:15the file size down as much as possible you can use a little tool called Compact & Repair.
00:19You will find Compact & Repair either on the DATABASE TOOLS tab, here at the
00:23beginning, or on the FILE tab in the Info group here, either way will run the same tool.
00:31Go ahead and press the button, Access will close the Database file then run
00:34through some routine maintenance tasks, it throws out old log files and
00:38rebuilds indexes, and generally cleans up after itself, then the Database file
00:42is saved again and reopened.
00:44For some databases, the Compact & Repair process is so quick, you might only
00:48notice a little blink as the file is shut down and reopened.
00:51For others with lots of tables and records, it might take a bit more time and
00:55you'll see a Status bar in the bottom of your screen down here.
00:58Depending on the size of your database file and how long it's been since the
01:02last time Compact & Repairs has run, you might see a dramatic decrease in the
01:05amount of disk space that your file takes up and simultaneously a dramatic
01:09increase in the speed at which your queries and reports take to run.
01:13Compacting and repairing your database is a common maintenance task that you
01:16should run periodically to keep your database in good health.
Collapse this transcript
Examining database object relationships
00:00When you're working with a large database, or you need to explore the inner
00:03workings of a database that somebody else created, it's important to understand
00:07how all of the objects interrelate.
00:09We've seen how you can use the Relationships map to explore the relationships
00:13between multiple tables, but that doesn't tell you what queries rely on specific
00:17tables, or which forms send data to a certain report.
00:21To get a deep dive into the interconnectedness of all of your objects, we are
00:25going to turn to the Object Dependencies tools on the DATABASE TOOLS ribbon.
00:28You can find Object Dependencies here.
00:32Go ahead and select it, and if this is the first time this tool has run, you
00:35might be prompted to rebuild the dependency information on your database.
00:39Press OK and Access will analyze all of your objects to see where they connect.
00:43Once that's done, you'll see this Dependencies pane open up on the right.
00:46We can go ahead and click on the edge and drag open to give ourselves some more room.
00:51Now I always get a laugh at the fact that the two options on the top of the
00:55pane are written in first person, objects that depend on me and objects that I depend on.
01:00Me, and I here refer to the currently selected object, over in your Navigation pane.
01:05Choosing objects that depend on me displays the objects that use the selected
01:09object as an input or source.
01:11Typically, tables are sources for information that gets passed into queries and reports.
01:16If you change the view to objects that I depend on, you'll see which objects
01:20feed into the selected objects.
01:22Usually reports and queries require tables.
01:25Let's go through and take a look at some of these relationships.
01:28I am going to scroll down and choose the Customer Spend query.
01:33I'll go back up in changes to objects that depend on me and then I'll press this
01:37Refresh button over here to update the list.
01:40I can see that the objects that depend on the Customer Spend query, is this
01:44Customer Spend report.
01:46Now what objects does the Customer Spend query depend on?
01:49Well, we can change the Radio button here, and see that the Customer Spend
01:53query requires the Customers table, the Orders table, the Products table and the States table.
01:59Let's take a look at one more.
02:00I'll scroll down and I'll take a look at the Training Department Employees.
02:05I'll go back up here to the Object Dependencies panel and press Refresh.
02:10Now I can see that the objects that I depend on, that is the objects that
02:13the form depends on, is the Employees table and the
02:17Employees-TrainingDepartment query.
02:19I can switch my button here, and see that the objects that depend on the
02:23Training Department Employees form is the Navigation Form.
02:27Once you have done exploring the Dependencies, you can simply close the panel by
02:31pressing the X in the upper-right-hand corner.
02:33As your database grows in size, you'll have lots of interconnections between all
02:37types of objects and if you find yourself in a position where you need to alter
02:40the underlying structure of an object, say renaming a field on a table, you
02:45might want to go through all of your related objects to ensure that the changes
02:48made don't break any functionality down the road.
02:51The Object Dependencies tool is a great one-stop location to reminding yourself
02:55where those connections occur.
Collapse this transcript
Documenting your work
00:00The only thing worse than opening up an unfamiliar database and realizing that
00:04you can't figure out what the creator was thinking when they put it together,
00:08is opening up a database that you yourself created and not remembering why you
00:11did it the way you did.
00:13I'm a big proponent of keeping a detailed documentation trail inside of the database file.
00:18Fortunately, Access provides lots of opportunity for you to leave notes to the
00:22next database designer that has to follow in your footsteps.
00:26First, let's go ahead and open up the Customers table.
00:29I'll right-click on it, and switch directly to Design View.
00:32Each field has an Optional Description area where we can type a note describing
00:36the type of data stored.
00:38For instance, the two notes we put in earlier.
00:40The State is a Two letter state abbreviation and the EMail is their
00:44primary contact e.mail.
00:46This Optional Description area is a great place to store any specific notes on
00:50the formatting or requirements of each data field.
00:52I'll go ahead and close this table.
00:54If you right-click on a Table, or in fact actually any object in the Navigation
00:58pane, you can go into the Properties for that object down at the very bottom.
01:03In the Properties, there is a Description field where we can type in what
01:07this data table is for.
01:08I'll type that this table so as the Customer list for No Obstacles.
01:13Go ahead and say OK to save that change.
01:15When working with queries, specifically queries that use a complex calculation
01:19or function, it's useful to put a quick human readable description of what that
01:23calculation is doing.
01:24I'm going to go ahead and open up one of our queries that we worked on.
01:28I am going to find the Customer Spend query, right-click on it, and go to Design View.
01:33Here at the end, I have got a calculated field, that's finding customer's total
01:37amount that they spent with the company.
01:39I am going to put a Comment here.
01:41I can right-click on the field and open up the Property Sheet for that field and
01:45here in the Properties, I have got a Description field.
01:47Now you can either type here or right-click there and press Zoom to get a larger
01:52window where you can type.
01:54Here I am going to type Calculates the total lifetime spend for each customer by
01:59adding up the total transaction price for all orders placed.
02:03Go ahead and press OK to save that property description.
02:07Now it adds up to my Description field, so anybody who's curious as to what this
02:11calculation does, can see it right here.
02:13Go ahead and close the Property Sheet and then we'll close and save the query.
02:17Let's scroll down in our Navigation pane.
02:20On Forms, we have two useful features that we can enable to help guide your users.
02:24I am going to go ahead and open up the Training Department Employees table and
02:29I'll right-click and go straight to Design View.
02:33Now in the top of our Form, I have got this Search box right up here.
02:36Let's add some descriptive helpers for our users.
02:38I am going to click on that and open up the Property Sheet.
02:42Now for the properties on that control, on the Other tab, we have got two
02:46properties I want to take a look at.
02:48This ControlTip Text will be a little pop-up flag that will come up when the
02:52user hovers over the control.
02:54I am going to type here Search:
02:56Choose a name, or just start typing.
03:03Down a few more lines, we've got the Status Bar Text.
03:06The Status Bar Text will be a little flag that shows up right down here in this area.
03:10Go ahead and type in here 'Jump to a specific Employee'.
03:17Let's go ahead and close the Property Sheet and we'll close and save the form.
03:23Now let's try it out. I'll open it up.
03:25When I go up to the Search box and click, you'll see the little pop-up flag
03:29here, saying 'Search:
03:30Choose a name or just start typing' and down in the bottom left-hand corner,
03:34Jump to a specific employee.
03:36Let's go ahead and close this form.
03:38When creating a macro object, you can add a comment field that allows you to
03:42describe what the procedure does or which object it is connected to.
03:45I am going to go down to this disabled macro here.
03:48I am going to right-click on it and jump into Design View.
03:51Now we'll go to add a new action.
03:53One of the actions that we can is a Comment.
03:56If I start typing Comment, you'll see that pop up and when I press Enter,
04:00it gives me a new Comment field.
04:01Here, I can say this action runs when the database starts.
04:06Now I can move it up to the very top, so that anybody, reviewing this macro, can
04:11see instantly what it was created for.
04:13I'll go ahead and close and save my macro.
04:17I personally don't think it's possible to over-document your work.
04:20Adding appropriate comments can aid someone else down the road help understand
04:24the database's structure.
04:25And when you need to get up and running on a new database file quickly, you'll
04:30be glad to find that the person that created it before you, took the time to
04:34leave notes behind as well.
04:35Taking the time to document what you do and why is an important piece of being
04:39a great database designer.
Collapse this transcript
Printing the blueprint of your database with the Database Documenter
00:00Occasionally, you may need to provide a written set of specifications on how
00:04your database was created and all of the details about what makes it tick.
00:08A tool, called the Database Documenter, makes that task as easy as pressing the Print button.
00:12You will find it in the Database tools ribbon, under Database Documenter.
00:18Starting the tool brings up a window that gives you the opportunity to select
00:21which objects you'd like to document.
00:23We can choose from our Tables, our Queries, Forms, Reports, Macros, everything
00:30in our current database, including the Properties and Relationships, any Visual
00:34Basic modules we might have or we can choose all object types.
00:38I am going to choose a couple of objects from our Tables and Queries group.
00:41Let's choose our Customers table here and switch to the Queries group and choose
00:47our Customers-WestRegion query.
00:50We'll go ahead and say OK to run the report.
00:53The report opens up in Print Preview mode.
00:55You can then click the page to zoom in or send it to the printer here or export
01:00it to a file such as a PDF or an Excel file.
01:04Let's see what's in the report now. I'll scroll up to the top.
01:06In the top, we'll have a header which gives us the date that the report was run.
01:11We can also see which file this report was run on.
01:14Below, we'll see the properties for this file, including any coloring or any
01:18styling that has been applied.
01:20Down below we've got the columns that make up this table, here is the CustomerID column.
01:25It's a Long Integer type, set to 4.
01:28We have got some various other properties about the CustomerID column and
01:31then we've got the FirstName column, that's Short text with a string of 255 characters.
01:36Following, got some additional details about that field.
01:40Now I can page through this report using the Report buttons down here at the bottom.
01:43We'll scroll through and see all the different fields that are in
01:46this particular table.
01:48We can also see the relationships that have been established between this table
01:51and other tables and the fields that they are linked by.
01:54We'll go ahead and scroll down and I'll keep paging through the document.
01:57Eventually, we'll get to the page for the query that we exported, here it is, Query:
02:01Customers-WestRegion.
02:03Again, we've got the properties for this query.
02:05The SQL statement or this is the programming code that generates that query, and
02:10the various columns that make up that query.
02:12Anything you can possibly want to know, about how this object was built, can be
02:16found in the Database Documentation Report.
02:18The Database Documenter is a great tool for generating the blueprint of your
02:22database and it's something that can be printed out or saved as a PDF file in a
02:26remote offsite location, just in case disaster strikes and you need to recreate
02:30your database all over again.
02:31It can also be a handy report to have when sharing the construction progress
02:35with your colleagues in order to get valuable input and feedback on the
02:38direction that you are taking.
Collapse this transcript
Splitting a database into front and back ends
00:00If your database will be used by several people at once, you should
00:03consider splitting it.
00:05Splitting a database converts it from one file into two linked files called a
00:09Back-end and a Front-end.
00:10The Back-end file will contain all of your data tables and can be stored on a
00:14network server so that everybody has access to the same information.
00:17Access provides a tool to easily split your database into two components and we
00:21can find it up on the Database tools tab.
00:23Here we are going to go to the Access Database button.
00:26Now even though the name of the button isn't very descriptive, the icon gives
00:29you an idea of what's about to happen.
00:31One database will become two parts.
00:34Go ahead and click that button.
00:36When you do, the Database Splitter Wizard opens.
00:38It gives you some instruction about what's about to happen.
00:41When you press the Split Database button, Access will move all of your data
00:44tables into a new file which could be moved to a commonly shared location on
00:48your company's network, for example.
00:50The remaining interface objects such as queries, forms and reports will become,
00:55what's called, the Front-end.
00:56Each user can keep a copy of the Front-end file on their local machine.
01:00This gives everyone the best of both worlds.
01:02When interacting with the database, running a query or printing your report for
01:06instance, the database runs quickly because it doesn't have to transfer each
01:09mouse click over the network, but you still get the benefit of having everyone
01:13share the same data tables.
01:15So for example, if somebody in a different department adds a new vendor,
01:19everyone accessing the database, will instantly be able to make use of that new
01:23vendor in their product orders.
01:25Go ahead and press the Split Database button and Access will ask you where to
01:28put the Back-end file.
01:30Notice that it adds up a 'be' at the end of the file name.
01:33This is a common convention that reminds you that this is the Back-end file.
01:36I am going to go ahead and save this into my exercise files.
01:39Go to the Desktop, into my Exercise folder and inside of the Chapter 12 (Ch 12) folder.
01:46Go ahead and say Split.
01:49Access tells us that the split procedure was completed successfully.
01:53Go ahead and say OK to dismiss the wizard.
01:56Now if you're looking your Navigation pane, you'll notice all of our tables
01:59have this blue arrow icon next to them, that indicates that they are now linked tables.
02:03And if you hover your mouse over them, you can confirm that their file location
02:07is indeed in that Back-end, _be file.
02:10Splitting your database provides an easy way to give each user their own
02:13customized Front-end with Forms, Queries and Reports specific to their tasks or
02:18areas of responsibility.
02:20By storing all of the data from those tasks into a commonly accessed Back-end
02:23file, stored in a network location, everyone in the organization will be
02:27pulling from and writing to the same pool of shared data, so that everybody is
02:32always up-to-date.
Collapse this transcript
Protecting the database with a password
00:00It's common for an Access database to include sensitive information that should
00:04only be accessible to people with the proper credentials.
00:07By establishing a password on your database file, you can keep your data secure.
00:11In order to password-protect our database file, we are going to go up to
00:14the File tab here and in the Info group, we are going to choose Encrypt with Password.
00:20When you do that, you'll get an information box here that says 'You must have
00:23the database open for exclusive use to set or remove the database password'.
00:27Go ahead and say OK.
00:28In order to open up our database in exclusive use, we actually need to close it first.
00:33Let me go to the File tab and choose Close Database.
00:37Then I'll go to File tab again and say Open.
00:41I am going to go into My Computer and then click the Browse button.
00:46I'll find the Exercise File in the Chapter 12 (Ch 12) folder and we are looking
00:51for the one called NoObstacles-Password.
00:53Go ahead and click on it one time, but don't double-click on it to open it.
00:57I'll select it and then go into this Open button here.
01:00On the right half of the button, you'll see this down arrow.
01:03Press that, and we'll get some additional options for opening our file.
01:06One of them is Open Exclusive.
01:09Go ahead and choose Open Exclusive on that database file.
01:12Now our database file is opened exclusively, that means that nobody else can
01:16open it at the same time.
01:18Now we can go ahead and set our password.
01:20Go to the File tab, in the Info group, Encrypt with Password.
01:25Now we can type in our password and go ahead and verify the password that you just typed in.
01:31Press the OK button to set your password.
01:33If you get this warning message, just press OK to dismiss it.
01:37Now our database is protected.
01:39If I go to file, Close again, and then go back to the File menu, Open and from
01:46my Recent menu I selected here, notice I'll have to now enter a password before
01:51it continues opening the file.
01:53I'll go ahead and type in the password and press OK and now I've gained
01:57access to my database.
01:59If I want to remove the password from my database, I'll have to go through the
02:03process to set up my file in Exclusive mode again.
02:05I'll go back to the File tab, close it, one more time to the File tab, Open>My
02:12Computer and Browse.
02:15I'll locate the file again, in my Exercise folder, in the Chapter 12 (Ch 12)
02:21folder, the Password file.
02:24I'll use the downward-pointing arrow and choose Open Exclusive.
02:28I'll have to enter in the password again and now I can go back to File, in
02:35the Info section, here is a button to decrypt the database which will remove the password.
02:40Setting a database password is a simple step that you can take to protect the
02:44information and contents of your database.
02:46Just make sure that you use a password you can remember or write it down in
02:49a secure location, otherwise you could find yourself locked out of your own database.
Collapse this transcript
Creating custom Ribbon tabs
00:00When working in Access you'll soon find that you have a small group of very
00:04commonly used tools that you've returned to time and time again.
00:07Some of these tools are already present in the ribbons, but some aren't.You can
00:11create a Custom Ribbon tab here at the top using your own set of commonly used
00:15commands in order to speed up your work.
00:17We can do that by going to the FILE tab and then clicking Options down at the bottom.
00:22From the Access Options window we're going to choose Customize ribbon.
00:26On the left side of this screen we have a list of all of the commands that we
00:29can add and on the right we have our current Ribbon structure.
00:32I'm going to go ahead and add a New Tab by pressing this button down here that
00:35will create this New Tab with a single Group inside if it.
00:38I'll click where it says New Tab ( Custom) and then click the Rename button.
00:42I'm going to give this a name No Obstacles.
00:45Go ahead and say OK and then I'll click on the New Group line and I'll rename
00:50that as well, I'm going to call this Favorites, go ahead and say OK.
00:55Let's add two additional groups here;
00:57I'll say New Group and New Group again.
01:00We'll click on the first one and rename it, this one is going to be our Design a
01:05New Object group, I'll say OK.
01:09And this group down here, I'll rename it, that's going to be our Daily Tasks and
01:15go ahead and say OK.
01:16So now I've got a new Ribbon with three groups in it.
01:19Now it's time to start putting buttons inside of these groups.
01:21I'll click on the Favorites group.
01:23And here we're going to put some buttons that'll quickly change from Form View
01:27to Datasheet View to Design View.
01:28I'll click on this Datasheet View button here and say Add, I'll do Design View
01:34here and press Add and I'll find Form View here and press Add.
01:39If I want to rearrange the buttons order, I simply select it here and move it up
01:43or down on the list.
01:44I'll move Form View to the beginning, then Datasheet View, the Design View.
01:49Next, let's add our button to our Design a New Object category.
01:52Here I want to put buttons that go straight to Table Design, Query Design, Form
01:56Design and Report Design.
01:58Now I'm not going to find them here on this list, but I can change Popular
02:02Commands here to All Commands.
02:04Then I'll scroll down the list until I find Table Design towards bottom and
02:08there it is here, I'll add this one, say Add and that will go down into my
02:13Design a New Object group.
02:14Now we'll go find the others Query Design, here it is, go ahead and add that
02:20over, then Form Design, here it is and then finally Report Design which is back
02:29towards the bottom and we'll add that over as well.
02:32Finally our Daily Tasks, here we could actually add our buttons to run our Macros.
02:37I'll go back up here to Choose commands from and I'll change it to Macros and
02:41from there I'll add our Good Morning Macro, Add that down to the list here and
02:45I can even change its icon by pressing on the Rename button here, that will
02:49bring up this list where I can give it a new name if I'd like and I'll choose
02:53an icon from this list.
02:54I like this push pin icon there, go ahead and say OK.
02:58Now if I wanted to move this Ribbon tab to the end of the list, I'll click on
03:02where it says No Obstacles here and I'll scroll down and press the down key
03:05until it gets all the way down to the bottom.
03:08Now it will appear at the end of the list of tabs.
03:11Let's go ahead and test it out, I'll say OK here and we'll see our new No
03:15Obstacle tab here at the top.
03:17If I click on it, you'll see all my Favorites, my Design a New Object and in
03:21fact a link to my macro.
03:22I'll press Good Morning and there are the three objects ready to get started at
03:26the beginning of the day.
03:27Creating a customized Ribbon tab with all of the tools that you use regularly
03:31can speed up your work by placing them all in one convenient location.
Collapse this transcript
Setting startup options and custom icons
00:00To give your database a polished appearance, consider setting some of
00:03the Startup Options.
00:04Let's take a look at what's available by going to the FILE tab here and
00:08going down to Options.
00:09That will open up the Access Options window and I'll choose Current Database.
00:13The first option is this Application Title.
00:16That will be what appears here at the very top of your screen.
00:18I'm going to change it to say No Obstacles.
00:21I can specify a custom Application Icon that will replace what shows up here in
00:26the top left corner.
00:27I'll choose my Browse button, go out to my Exercise folder, it's on Desktop in
00:31the Ch 12 folder and here I have our RecycleBug logo saved as an icon file.
00:36I'll go ahead and say on OK and that will add its path here.
00:40I can choose to display a Form when the database opens.
00:43This drop down will show me all of the form objects in my database.
00:46I am going to choose our Navigation Form.
00:49I can choose to Display the Status Bar or not.
00:51The Status Bar is what appears down here at the bottom.
00:53I also have options for how my windows open.
00:57Tabbed Documents is the default that opens up every object as tab that appears
01:01across the line here.
01:03The other option is Overlapping Windows that will make everything float on top of each other;
01:08I'll leave it as Tabbed Documents.
01:09We've got some options down below here, Enable Layout View.
01:14If I like to only use the design tools to create my objects I can disable
01:18Layout View altogether.
01:19And I also have an option here to Enable design changes for tables in Datasheet View.
01:24This can protect the structure by requiring all changes be made in the full Design mode.
01:29I'm going to turn both of those off.
01:31Down here I have an option for Display Navigation Pane.
01:34If I turn that off, Access will hide the Navigation Pane from VIEW when
01:37the database starts.
01:39Let me scroll down a little bit further.
01:41If you really want to keep people from getting into your database structure, you
01:45can turn off Allow Full menus;
01:47this will only leave the HOME tab and any Custom tabs that you may have created
01:51and the Print Preview Ribbon tabs available for people to use.
01:54Of course, if I turn this option off and the Navigation Pane option off, this
01:58will require that your database is structured in a way that all of your required
02:01task can be accomplished through the use of well organized forms, navigation
02:05controls buttons and macros to move from object to object.
02:09But if that's the case, turning off the Navigation Pane on the Ribbons can keep
02:13other users away from objects that they shouldn't be adjusting.
02:16Once you've made all of your selections, go ahead and press OK down here at the bottom.
02:20Now Access will tell me that I need to close and reopen the database for the
02:24options to take effect.
02:25Go ahead and say OK and you can go to the FILE tab and Close and then once again
02:30FILE>Open, from my Recent menu, I'll click Startup here.
02:35Notice that a bunch of things are a little bit different.
02:37First I've got my Title up here at the top, I've got my logo over here on the
02:40left, I'm missing most of my tabs except for the HOME tab, my Navigation Form
02:46opened up and my Navigation Pane is completely hidden.
02:49Now I should point out that the Navigation Pane isn't completely gone, you can
02:52bring it back by pressing F11 keyboard shortcut key.
02:55Now we can bypass all of the Startup Options by holding down the Shift key when
03:00we open our database.
03:01I'll go ahead and close everything down by going to the FILE tab and then pressing Exit.
03:05And then I'll go back out to my file by clicking on it here, I'll hold the Shift
03:09key down while I double-click on the fileto open it and all of my Startup Options get bypassed.
03:14Notice that Environment is reset back to the way it was before I changed those options.
03:18Once your database is fully developed and its time to get down to the day-to-day
03:22management of your data, entering records and printing reports, it's a good idea
03:26to limit the amount of exposure you give to the design tools.
03:29They'll still be there when you want to make structural changes to the database,
03:32but they're really not required for general operational tasks.
03:35It's safer if you keep them off the screen to keep everyone, including yourself,
03:39from accidentally breaking something that you've worked so hard to perfect.
Collapse this transcript
Conclusion
Next steps
00:00I want to thank you for joining me as we got to know Microsoft Access 2013.
00:05If you would like to expand on your knowledge, let me make the
00:08following suggestions.
00:09At the beginning of this course, I mentioned that the templates that come with
00:12Access are a great resource for further exploration.
00:14I'm going to reiterate that point again and encourage you to go through and
00:18download some of the templates to explore.
00:21Really dig into them and see how they function.
00:24Take some time and review their table structure and their relationships, then
00:27run a few queries, see what their results are and switch into Design View to see
00:31how it was constructed.
00:33Deconstruct the forms and reports in Layout and Design Views and don't forget to
00:37peruse the Property Sheets for all the details on each object.
00:39You'll be surprised that how much you can quickly pick up by seeing other
00:43databases at work.
00:45If you want to dig even deeper, lynda.com offers courses on Visual Basic and
00:49Structured Query Language in addition to in-depth courses on Access.
00:52We're always adding new and updated content, so check back regularly to see
00:56what's new in the world of database design.
00:59I hope you've enjoyed your time exploring the ins and outs of Microsoft Access 2013.
01:04Until next time, have a great day!
Collapse this transcript


Suggested courses to watch next:

Office 2013 New Features (2h 31m)
David Rivers

Excel 2013 Essential Training (6h 32m)
Dennis Taylor


Access 2010 Power Shortcuts (3h 43m)
Alicia Katz Pollock


Are you sure you want to delete this bookmark?

cancel

Bookmark this Tutorial

Name

Description

{0} characters left

Tags

Separate tags with a space. Use quotes around multi-word tags. Suggested Tags:
loading
cancel

bookmark this course

{0} characters left Separate tags with a space. Use quotes around multi-word tags. Suggested Tags:
loading

Error:

go to playlists »

Create new playlist

name:
description:
save cancel

You must be a lynda.com member to watch this video.

Every course in the lynda.com library contains free videos that let you assess the quality of our tutorials before you subscribe—just click on the blue links to watch them. Become a member to access all 104,069 instructional videos.

get started learn more

If you are already an active lynda.com member, please log in to access the lynda.com library.

Get access to all lynda.com videos

You are currently signed into your admin account, which doesn't let you view lynda.com videos. For full access to the lynda.com library, log in through iplogin.lynda.com, or sign in through your organization's portal. You may also request a user account by calling 1 1 (888) 335-9632 or emailing us at cs@lynda.com.

Get access to all lynda.com videos

You are currently signed into your admin account, which doesn't let you view lynda.com videos. For full access to the lynda.com library, log in through iplogin.lynda.com, or sign in through your organization's portal. You may also request a user account by calling 1 1 (888) 335-9632 or emailing us at cs@lynda.com.

Access to lynda.com videos

Your organization has a limited access membership to the lynda.com library that allows access to only a specific, limited selection of courses.

You don't have access to this video.

You're logged in as an account administrator, but your membership is not active.

Contact a Training Solutions Advisor at 1 (888) 335-9632.

How to access this video.

If this course is one of your five classes, then your class currently isn't in session.

If you want to watch this video and it is not part of your class, upgrade your membership for unlimited access to the full library of 2,025 courses anytime, anywhere.

learn more upgrade

You can always watch the free content included in every course.

Questions? Call Customer Service at 1 1 (888) 335-9632 or email cs@lynda.com.

You don't have access to this video.

You're logged in as an account administrator, but your membership is no longer active. You can still access reports and account information.

To reactivate your account, contact a Training Solutions Advisor at 1 1 (888) 335-9632.

Need help accessing this video?

You can't access this video from your master administrator account.

Call Customer Service at 1 1 (888) 335-9632 or email cs@lynda.com for help accessing this video.

preview image of new course page

Try our new course pages

Explore our redesigned course pages, and tell us about your experience.

If you want to switch back to the old view, change your site preferences from the my account menu.

Try the new pages No, thanks

site feedback

Thanks for signing up.

We’ll send you a confirmation email shortly.


By signing up, you’ll receive about four emails per month, including

We’ll only use your email address to send you these mailings.

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

By signing up, you’ll receive about four emails per month, including

We’ll only use your email address to send you these mailings.

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked