Join Adam Wilbert for an in-depth discussion in this video Organizing the form elements, part of Access 2007: Forms and Reports.
Combining the Form Wizard and Layout View are easy ways to get started creating your database's forms. But the real power and flexibility lies in utilizing the full design environment for creating forms from scratch. Once you understand what's going on under the hood, creating your own forms that meet your exact specifications and needs will become second nature. Let's start by creating a Rolodex style Employee Directory for Two Trees. Now I have got a completed example here in my database called frm_Employees-Complete. I will double click on that to open.
Now this is an example of what we might be shooting for. Now, because some of the design decisions that we are going to make while creating our form are going to be a little bit subjective, our finished form might be a little bit different than this one, but this is the idea of what we are shooting for. We are going to have a scrollable form that will show all of our employees within the company, we will have their photo and their name and some details about the employment. And it will have this header at the top with a title, and that part doesn't scroll as we move through the records. And it's got a couple of design elements such as the shaded background on every other record and some playful fonts here for the employee ID number and the state that they are in.
So let's see how we can duplicate this using the Design view. I will go ahead and close this format and we will start a new one by going to Create and then Form Design in the Forms group. This will open up a blank form in Design view and I can see that I have got this grid here in the background with these dots in the gridlines. And this is an alignment grid; this will help us organize our elements within the form and make sure everything is lined up. So these dots aren't going to show on the final form. Now when I start a new form in Design view, the first thing I needed to do is link this form to the particular table that the data will be pulled from.
Now with that open, you can open up the field list by going to Design ribbon and clicking on Add Existing Fields. That will open up this Fields List here and from it we can see a list of all the tables within our database, and if I open these up by pressing the plus button, we'll see all the fields within each table. Let's go ahead and open up my Employees table, tbl_Employees. And I will find the FirstName field and I will double-click on that to add that to my form. Now when I do that, a couple of things happen. First I get a FirstName field here put into my form.
And now that I have also told my form that the data will be becoming from the Employees table, it changes the field list a little bit to show me some related tables and the fields that are within those tables that are related to my Employees table. Over here on my form, I have got these two objects that appear. This one here on the right with the white background is the text box and that's where the data will show up as I scroll through the records. The one on the left is a label, and every object that you add to your form will come with a label.
The label is a static piece of text that just tells the end-user what appears to the right. If I switch into Form view at this point by clicking up on the View button, this Form button, I can see that the label still reads FirstName, whereas the text box changed to the data for the first record. If I scroll through the records down here on the bottom, I could see the first name of each of my employees. Let's go back into Design view by clicking View > Design View. Let's add the other fields to our form and then we'll move them around and arrange them into position. From the Field list, I will double- click on LastName, Phone number, Address, City, State, Zip, Email, HireDate.
I don't want everybody's hourly pay showing up, so I will skip that one. We will do Department, Photo, and then back at top, the Employee ID number. Now I have got all of these listed on my form, some of them are overlapping a little bit, like the LastName appeared right on top of first name. If I click on it I can drag it by using this orange handle around the edges. So I will click and once I get the double headed arrow, I can drag off of it. So now they are separated. Now when you move an object the label comes with it. So for instance, when I just move that LastName box, the label for LastName moved with it.
If I drag on the object around the edge right anywhere where I can see the crossed arrow, that'll move both the label and the object at the same time. So for instance, if I grab here, click and drag, that will move the text box and the label with it. If I use the handle in the upper left- hand corner, I get the same icon, but I can move the objects independently of each other. So for instance, I could take this last name and drag it using the handle on the upper left corner and put it below the label, and it moves it like that.
Now if I drag using the orange box around the edge it maintains that new special relationship between the text box and the label. The other handles around the edge will allow you to resize, so I could drag it to the left, drag it down to the left, make it taller, make it wider. So let's go ahead and arrange these onto our form, and we are going to move the objects around and put them into position. Now some of the labels might be a little bit redundant. For instance, the data that appears in First and Last Name, I am going to be able to understand that that's the first and last name for my employee; I don't need a label that says this is the first name, this is the last name.
So I can get rid of some of these redundant labels. I am going to get rid of the FirstName label by clicking on it and pressing Delete. LastName, click on that label and press Delete. I also want to get rid of some of these that are associated with the address. I can leave one that says address, but for City, State, and Zip, I am going to have all of these boxes grouped together. The end users, I think, will understand that Address, City, State, and Zip all are part of the address. I don't need a label that says now this is the City, now this is the State, now this is the ZipCode. So we will get rid of these three.
I can select multiple objects by Shift+ clicking, so I will press Shift and click on the other two for City, State, and Zip, and I'll press the Delete button to get rid of those labels. Photo is the same way, I don't need a label to tell me that this is a picture. I will click on the Photo label and press Delete. Let's start moving these into position. I will drag my FirstName box and I am going to put it up here just to the right of the two inch marker. I will take LastName and drag it and put it to the right of that. I am going to move Phone number below FirstName.
And I am also going to take the Email address and put that below Phone number. So click on Email, drag that up. Below that, I am going to display the address. We will click on Address and I will move that over. Below Address, I can put City, State, and Zip all in one line. So City, I will drag that and put it in position. State, I am going to drag that to the right of City. And Zip, I will put to the right of State. HireDate and Department, I will go ahead and put it below the address, and maybe I'll put Department over here to he right.
I can also use the Arrow keys to move things around, so I can nudge the objects on the form by pressing the Down key and the Right key to move things into position. Let's go ahead and move these labels over. So that I have a little bit of room, I want to put the photo over here on the left side. So I want to move these labels for Phone number, Email, Address, and HireDate out of the way a little bit. I will go ahead and click on HireDate one and using the brown handle to move it independently of the HireDate text box, I will scroll that over a little. And once it's in position, I can actually use its position align the other objects.
So if I drag a box around all four of these, I can go up to the Arrange tab and click on this Right button and that will align all of the objects to the rightmost object. And so they all line up. Now I have got room for my photo, I will click on the Photo box, drag that up, and I can make it a little bit bigger. Now I have got something special in mind for the Employee ID number. What I would like is for that to display on top of the photo, kind of like a little transparent box or an ID tag that you might see on a badge or something.
So I am going to get rid of this label, I will click on the EmpID label on the left, and press Delete. And I will drag the EmpID number field and I will drag that, and I am actually going to put it over the Photo box. So you can see the Photo box here in the background. Now because I have related tables here, I am pulling in information from my employees data table, I can relate other data tables within my database. For instance, I have got a two letter state abbreviation stored with each employee. And from that, in my States lookup table I can grab the full StateName.
So I am going to take this, in the fields available in related tables section of my Field List, and I am going to double-click on StateName to add that to my form. Get rid of the label, and I will move that up. Now I am going to have a little bit of fun with the StateName label in the next movie, but we can finesse these positions as we continue to develop our form and truth be told, form design is going to require a lot of back-and-forth as the final layout gets further refined. Let's take a look at where we are at this point. I am going to go back to the Design tab and click the View button, and switch back into Form view.
Incidentally, I could also to go the Home tab and find same button there. I'll switch back into Form view and we will see my form there with elements in position. Not all of my employees have photos associated with them, so I can scroll through until I find one, say record number six for Nicholas Bond, has a photo attached. One thing before I leave here that you can notice is that some of these boxes need to be a little bigger. Address for example, Email address need to be a little bit bigger. Same with Department ID. So we are going to make these a little bit bigger. Switch back into Design view real quick, by clicking the View down button > Design View.
And we will make Address wider by clicking on it and dragging to the right, and make Email wider by dragging to the right And I will make Department wider. I drag this to the left, I have room there, and we will see how that looks. Switch back to Form view, and now everything is looking like it's fitting in its box properly. Now that we have our Form field elements in roughly the positions that we want them, we could take a look at some of the formatting options that are available to us. We will pick it up there in the next movie.
- Designing for the end user
- Organizing form elements
- Formatting a form
- Adding headers
- Linking to external content
- Entering and selecting data
- Adding charts
- Creating a main menu
- Creating a customer form
- Understanding report structure
- Building reports from wizards and queries
- Printing reports