New Feature: Playlist Center! Pick a topic and let our playlists guide the way.

Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Adding buttons

From: Access 2010: Forms and Reports in Depth

Video: Adding buttons

Buttons are one of the key interactive elements that you'll use on forms. They instantly tell the end user that something will happen when I click there. Buttons will be linked to either Macros or Visual Basic code to control their behavior. Like the other controls, you add them to reports as well for navigation within your database. But the nice thing about buttons is that they don't print when you print your report. Let's take a look at adding some buttons to my Controls form. I'll right-click on that form in the Navigation pane and choose Design View. The Button control is this one right here, the rectangle at the Xs inside of it. I'll go ahead and click that once and click to add a button to my form.

Adding buttons

Buttons are one of the key interactive elements that you'll use on forms. They instantly tell the end user that something will happen when I click there. Buttons will be linked to either Macros or Visual Basic code to control their behavior. Like the other controls, you add them to reports as well for navigation within your database. But the nice thing about buttons is that they don't print when you print your report. Let's take a look at adding some buttons to my Controls form. I'll right-click on that form in the Navigation pane and choose Design View. The Button control is this one right here, the rectangle at the Xs inside of it. I'll go ahead and click that once and click to add a button to my form.

When I do that the Command Button Wizard starts, and it asks what do I want my button to do? This first section has Categories; the second section has Actions within each category. So for instance, I've got Record Navigation, and I can do Find Next or Find Record or Go To Next Record or Last Record. Under Record Operations I can Add New Records or Delete Records, Print or Save. Under Form Operations I can apply a filter, close or open a form, I can send a form to a printer, or refresh the data. Under Report Operations I can choose to Mail a Report or Print a Report.

The Application category only has one action and that's to Quit Access or quit the entire program, and finally the Miscellaneous category has things like Print a Table or run another Macro. Let's go ahead and choose one of these options. I'm going to go to Form Operations and I'm going to choose Open Form. We'll go ahead and say Next, Access then asks me well, which form do you want to open? I want to open up the Employee Directory; we'll go ahead and say Next. Access asks us if we want to open the form to a specific data or open the form and show all the records. I want to display the entire thing, go ahead and say Next. And finally, what do I want all my button? Do I want Text or do I want a Picture, and if I want a picture, I can browse and find an icon or I can accept the default here.

We'll go ahead and choose Picture, and we'll accept this default one here. Let's go ahead and say Next, and we'll accept the default name for this button and say, Finish. Now I've got a button on my form. I'll go ahead and deselect it, so I can see what it looks like. Now buttons have lots of properties that we can change. For instance, I selected that I wanted an image on my button, but what if I wanted an image and text? Well, I can do that over here in the Format tab for the button. Right now it says Picture Caption Arrangement: No Picture Caption. Let's go ahead and change that to Right; that will add a caption to the right side of my image. Let's make the button a little bit bigger, I'll drag on the right side and I'll make it a little shorter.

Now I can change the text here with the Caption. So instead of just the icon, I can have, say, Open Employee Directory, and again, I'll have to make it a little bigger or I can go to the Format tab and change the font, I'll make it a little smaller, to an 8 point. I can also change the font down here; Font Size is now set to 8. Let's see some other things that we can change with our buttons. I can go up to the Quick Styles button here in the Format tab and choose a style that I like. May be I want to make it look like this green light button. Now it's got a shadow and it's green colored. I can click on the button and take a look at Shape Effects. We can add Shadows or Glow, or Soft Edges, or even make it Beveled.

Now I want to caution you against using some of these especial effects. A lot of times we can just add unnecessary clutter to your forms, they don't actually add anything to the user interface. And I'm going to leave all these alone and let's go back and take a look at some more properties here. Some of the other things that I can do is change the color when the user interacts with it. So for instance, I've got Hover Fore Color right now or Pressed Fore Color, the Hover state is what happens when the mouse moves over the button, the Pressed state is what happens when the user clicks down on the button, we can change both of these. Hover Fore will change the color of the text, so instead of that black color, maybe we'll make the checks change to dark gray.

The Pressed Fore Color will change the color of the text when it's pressed, so instead of black, we'll make it red when it's pressed. The Hover Color and Pressed Color will be at the background of the button. So we'll set the Hover Color may be to a darker green, here, and the Pressed Color, maybe we'll make that red. I'll hit the Build button and I'll choose a nice red. Let's go ahead and see what my button looks like now. I'll go to the Home tab and switch to Form View and now if I hover over the button, you see the color has changed to a gray color. As I hover over it, it changes color and as I click down on it, it changes too. So I can see it's got a light pink background with a red text.

If I click on the button; it's going to open up my Employee Directory, so it's doing exactly what I told it to do. Let's go ahead and close the Employee Directory and we'll switch back into Design View for our Controls form. Now I can control what the button is doing when I click on it from the Event tab in the Property Sheet, when we went to that wizard it was creating this OnClick event which means when I click on it what happens, that runs this in Embedded Macro. I can see what the embedded macro is by clicking the Build button to the right. Or if I have other macros that are already saved in my Navigation pane here, I can use the drop-down menu to select from those. I'll click Build to edit the Embedded Macro. When I went to the Wizard I told that I wanted to open the form, so I created this Openform event.

I also told it what form I wanted to open, so it attached that here. But it didn't ask me some other options, for instance, Window Mode or Data Mode or if I wanted to apply some filtering. So these are additional options that I can choose to add into this Openform Button, for instance, Window Mode, they don't change that to dialog, in which case the Employee Directory would open up as a pop-up menu. Let's go ahead and close this and see what that looks like. I'll return to Form View, and now I'll click on the Button, and the Employee Directory opens as a pop-up menu instead. So buttons provide the main interactive interface through the Access database. They leverage Macros or Visual Basic code to perform the actions, and they're instantly recognizable for your end users.

So when somebody sees a button on a form, they know that they can click on it and that will affect the database.

Show transcript

This video is part of

Image for Access 2010: Forms and Reports in Depth
Access 2010: Forms and Reports in Depth

38 video lessons · 14178 viewers

Adam Wilbert
Author

 
Expand all | Collapse all
  1. 1m 27s
    1. Welcome
      1m 2s
    2. Using the exercise files
      25s
  2. 15m 53s
    1. Introducing forms
      2m 41s
    2. Designing for the end user
      45s
    3. Exploring the database
      1m 49s
    4. Creating a form with the Form Wizard
      6m 43s
    5. Refining the form in Layout view
      3m 55s
  3. 24m 33s
    1. Organizing the form elements
      7m 14s
    2. Formatting
      4m 48s
    3. Modifying the form through its properties
      6m 56s
    4. Adding a header and some polish
      5m 35s
  4. 1h 2m
    1. Introducing form controls
      3m 48s
    2. Using lines and rectangles
      2m 48s
    3. Organizing screen space with tabs
      4m 47s
    4. Adding buttons
      5m 3s
    5. Linking to external content
      4m 15s
    6. Entering and selecting data
      5m 8s
    7. Controlling input with option groups
      6m 0s
    8. Attaching documents
      6m 49s
    9. Attaching images
      5m 8s
    10. Understanding the subform control
      4m 13s
    11. Adding charts
      7m 9s
    12. Linking controls
      7m 41s
  5. 21m 42s
    1. Creating the main menu
      8m 49s
    2. Adding a splash screen with startup options
      5m 35s
    3. Creating a customer form
      7m 18s
  6. 45m 20s
    1. Grouping and sorting data
      4m 36s
    2. Understanding report structure
      6m 12s
    3. Building reports from wizards
      5m 0s
    4. Building reports from queries
      6m 34s
    5. Formatting conditionally
      6m 59s
    6. Calculating fields
      4m 35s
    7. Adding the finishing touches
      4m 49s
    8. Populating pre-printed documents
      6m 35s
  7. 15m 8s
    1. Printing reports
      3m 6s
    2. Tweaking the design
      7m 10s
    3. Automating the workflow with macros
      4m 52s
  8. 58s
    1. Next steps
      58s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold

Are you sure you want to delete this note?

No

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

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.

Sign up and receive emails about lynda.com and our online training library:

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

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.