Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
The User Interface Macro is one that gets triggered when you click somewhere on a form. In the Access 2010 Essential Training course, you learned how to attach a macro to a button. In this lesson, you will see how to trigger a macro just by clicking in a Form field. Open up your Customers Order Form, and let's say you are looking at the form, and it would be handy to have quick access to the SalesReps contact information just by clicking in the SalesRep field. There are a few steps to this process. First, I have to create the little pop- up form, then I have to attach it to the SalesRep field using an Event macro.
So click on the SalesReps table, go to the Create tab and choose Form Design. Click on Add Existing Fields. We're going to add-in from the SalesReps table EmpID, LastName, FirstName, CellPhone and Email address. Now, I have to do a few things here to transform it into a small pop-up. I will highlight all of the controls, go up to the Format ribbon, and change these to size 9. I will also move them up to the top of the form.
To make it a smaller window, I will pick up the right edge of the form and move it all the way in and scroll down and bring up the bottom of the form as well. So that's just a little window with these cells. I will right-click on the form, and save it, and I will call it SalesRepsPopup, and click OK. Then I will right-click on the Tab and close this window. Now, in our Customers Order Form, change it to Layout view and open up the Property Sheet.
Click on the SalesRep field, because that's the field where we want to attach the event. Here are all my options for when this could happen. Now, I have to be careful with using something like On Click or On Enter, because I do have a dropdown list, and I don't want to trigger the popup when I go to use the dropdown list, or even just by clicking in the field. So I am going to use On Dbl Click. I will click in that row. Now these two buttons indicate that there's two ways that I could approach this macro. If I would like to use this macro to popup the SalesRep contact information several places throughout my database, instead of doing it right here, I would go to the Create ribbon, create the macro and then pick that macro off of this dropdown list.
But if I only want to trigger this event on this one form, I'll use my Builder button right here. I will click on it, and I get a Choose Builder. I will double-click on Macro Builder. What I want the event to do is open up a form. So I will scroll down, and choose OpenForm. First, it would like to know what form to open. I will click on the dropdown and I will choose the SalesRepsPopup. I want to view it in Form mode; I don't want to filter it. But where condition is really important, this is where you tell Access which SalesRep to put in the popup and you wanted to equal the SalesRep that's in the field.
The field in the popup that has the employee data is [EmpID, and we want that to equal the field in our form.] I will put-in my exclamation point and choose the Customer Order Form, put-in another exclamation point, and my SalesReps ID, which is in the field SalesRep. So this is saying that the employee ID on the pop-up form needs to match the employee ID of the SalesRep field.
For Data mode, I need to change this to Read Only, because I don't want anyone to change the SalesRep data from that little popup. Then in the Window mode, I will make this a dialog box. Go ahead and close that macro and save it. Let's go to the Form view and test it out. If I just click on the dropdown, it works normally, but if I double-click in the field, up opens my SalesRep pop-up with my SalesReps contact information. This is just one example of a User Interface macro.
You can get creative with what happens wherever you click, extending the usability of your Access database.
Get unlimited access to all courses for just $25/month.Become a member
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.