Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
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.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 70650 Viewers
80 Video lessons · 127705 Viewers
52 Video lessons · 62574 Viewers
59 Video lessons · 48290 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.