The basic forms and reports access creates are just that--basic.If you want to customize them you can use two of the Me Objects properties to do so.The Caption property controls the text that appears on the form or report'stitle bar, while the Picture property contains a reference to the object'sbackground picture.In this movie, I'll show you how to use those two properties to control yourform or report's appearance.For this exercise, we'll use the Orders report,so I'll right-click it in the Navigation pane and then click Design View.

Doing so opens the report in Design view.Now I'm going to right-click anywhere in the body of the report, then clickBuild Event. Then in the Choose Builder dialog box click, Code Builder, and then click OK.When I do, Access creates a new code module for the Detail_Format event, in otherwords, if we were to change the format of the detail section of the report.That's not actually the event that I want to trigger this code.Instead, I want this code to run when the report is opened.

So I'm going to go up to the Object list, which is just below the title bar,click the down arrow, and then click Report.Report is the object from which I want to choose my event. And the event thatappears by default is the Report_Open event, and that is the one I want to use.Now I'll press Enter twice and the up arrow key once to give myself a littlebit of room to work.Now I'm going to type in the code that will set a value for the caption, and that is Me.and then the Caption property, Caption =, then double quotes, and whatever youwant to appear on the caption or appear on the title bar.

In this case, I want that to be orders in the last year,so it would be Orders in the Last Year and then double quotes again.I'll press Ctrl+S to save my work and then press Alt+F11 to go back to themain database window.Now with the Order Report still there, I'll press Ctrl+W to close it. And now inthe Navigation pane, I'm going to double-click Orders Report to open it.

When I do, the code that I just assigned to the Report_Open event should run, andwe should see the new value on the title bar.So I'm going to double-click Orders Report, and there we see it, Orders in the Last Year.The other change that I'd like show you is how to add a background image, and thebackground image uses the Picture property.I'm going to right-click the tab for the Report and then click Design View.Doing so opens the report in Design view.

Now I'll press Alt+F11 to go back to the Report_Open event module and then press Enter.The code to set a background image for a form or a report is Me.Picture =, thendouble quotes, and then you're going to need the full path, or directory filestructure, that leads to the image you want to appear in the background.In this case, I need to go to my Exercise Files folder,so I'm going to press Alt+Tab until my desktop is displayed, and thendouble-click Exercise Files, and then double-click Chapter09. And the file that Iwant to use is Confidential.png.

But I can't just type it in, and obviously I don't see the entire pathanywhere on the screen--it's not easy to get at.But what you can do is right-click the image that you want to set the link toand then in the shortcut menu, click Properties.In the Properties dialog box, you will see a Location value, and it has the path to your file.Notice that the mouse pointer is a cursor.It looks like an I bar at this point.That means that you can select that text,so Users\Curt\Desktop\Exercise Files\ Chapter09. Then press Ctrl+C to copy it,and then Alt+Tab to go back to the VBA Module.

Then press Ctrl+V to put in the path, at least to the directory that contains theimage, and now you need to type the name of the image with the file extension.So that would be a backslash.That's the slash that leans with the bottom on the right and the top to the left.Then this image is called Confidential.png and then a double quote, because allof that is a string.Now I'll press Ctrl+S to save my work and then press Alt+F11 to go back tothe main database window. And now I'll right- click the Report title bar and click Close.

Now when I double-click the Orders Report to open it, we see that we have Ordersin the Last Year and also Confidential.Now, Confidential is somewhat obscured by the data and the row structure withinthe report, but the image is there, and you can play around with the formattingto make that image either stand out more or drop more to the background.Setting the caption or background image for a form or report can communicate information about the object and make it easier to use.Never underestimate the power of appearances, but be sure your background imagedoesn't distract the user from your data.

Resume Transcript Auto-Scroll

Author

Released

10/6/2011

Enhance productivity by automating routine tasks and providing custom functionality not built into Access with a few basics in VBA code. Author Curt Frye introduces object-oriented programming and provides database designers with a foundation in the Access object model and the Visual Basic for Applications (VBA) programming language. The course covers automating tasks with macros, working in the Visual Basic Editor, writing functions, adding logic, reading data, controlling forms, and more.