Figure 15— Use the vertical l-bar to help you position the ContactNotes field. Figure 15— After you drop the ContactNotes field on the report, Access adds a label and text box control to the appropriate report sections. The ContactNotes field is too wide at this point, so reduce its width by dragging its right edge toward the left side of the report.
Now drag the ContactFollowUp field to the right of the Notes label using the same technique. Close the field list so that you can see the whole report grid and the right print margin. Because these controls are in a tabular control layout, if you resize the width of one of them, the others move to the left or right accordingly. Make any small adjustments you need to the widths of the fields so that you can see all the data, but make sure the ContactFollowUpDate field does not extend past the right print margin.
Your report at this point should look like Figure 15— Figure 15— Your report is beginning to take shape with all the fields now in place. Adding Totals to Records All your fields are in place, so now you can add some controls for counting the events and follow-ups. Start with adding a count of the follow-ups by right-clicking on the Follow Up? Figure 15— Click the Count Values command to create a control to total the follow-ups for each contact. Remember that when you created this report using the Report Wizard, you had to correct the Sum expression for the ContactFollowUp field to display a correct count of the number of contact events requiring a follow-up.
See page In this case, Access correctly creates an expression to total the number of True values in the ContactFollowUp field. The Count Records option, shown in Figure 15—53, would ask Access to calculate a simple count of the number of records in that group, which is not we want for this field. To align the total with the check boxes, click the new control-where you see the number 5-and then click the Align Left button in the Font group on the Format tab. Figure 15— Access creates an expression to count the number of True values for the ContactFollowUp field.
You need to create a similar count of event records for each contact, so right-click the first ContactEventTypeDescription field under the Phone field , and click Total Contact Type and then Count Values, as shown in Figure 15— Figure 15— Click the Count Values option to create a control to total the event records. Access now displays a correct count of the number of events.
Figure 15— Access now correctly displays a total of events for each contact. When the report is printed, it would be nice to have a page number at the bottom of the page. Click OK to close the Page Numbers dialog box.
In Layout view, Access does not count the number of pages because it is not actually formatting the pages for printing. If you switch to Design view, you can see that Access placed the control on the right side of the report in the Page Footer section. If you switch to Print Preview, you can see the correct page numbers displayed on each page. Applying an AutoFormat Your report is functional right now, but with a little formatting you can make it look more professional and also easier to read.
You could selectively add some color to certain controls to highlight specific areas, but here again you can let Access do most of the work. Access has 25 built-in AutoFormats to spice up your reports. You can easily click one of the AutoFormats to see what it would look like applied to your report.
Click the arrow under the AutoFormat button in the AutoFormat group on the Format tab to display the gallery of AutoFormats, and then click the Access style, as shown in Figure 15— Figure 15— Select one of the AutoFormats to give your report a more professional look. You see an instant change to several elements of your report. Access added some background color to all the labels going horizontally across the screen. The font size changed from 11 to 10 in some of the controls, and Access even added some alternating background color to the detail records, as shown in Figure 15— Figure 15— Access makes several visual changes to your report when you select an AutoFormat.
Save your report and then switch to Print Preview to see how your report will print on paper. The report still needs some fine-tuning to exactly match the reports you created earlier in this chapter. You need to add a label and a text box next to the two Sum controls in the ControlID Footer section to list the name of the contact and the descriptive text of follow-up information.
You could also move the Title control into the Page Header section so that it appears on every page instead of only the first page. You can find this report after we made these few changes saved as rptXmplContactEvents4 in the sample database. As you can see, Layout view allows you to quickly create a professional-looking report in Access This supremely organized reference is packed with hundreds of timesaving solutions, troubleshooting tips, and workarounds.
Discover how the experts tackle Access —and challenge yourself to new levels of mastery! For customers who purchase an ebook version of this title, instructions for downloading the CD files can be found in the ebook. The expert guidance you need to get the most out of Access Get the Access …. You're beyond the basics, so dive right in and customize, automate, and extend Access—using Visual Basic ….
Master database creation and management Access Bible is your, comprehensive reference to the world's most …. A comprehensive reference to the updated and new features of Access As the world's most …. As you click each form window, Access changes the Ribbon. You can see some useful differences between the two Ribbons, as shown in Figure 24—1.
None of the forms in the Conrad Systems Contacts database are designed to be printed. However, the custom Ribbon does have a Close Form button added at the left end of the Record Navigation tab, and we provided a custom Undo command because Undo is no longer available on the Quick Access Toolbar. In the Conrad Systems Contacts application, all forms except frmContactsPlain and a few other example forms have their Ribbon Name properties set to use the custom Ribbon.
The same is true of the built-in tabs. The following sections show you how to build a custom main Ribbon and custom Ribbons for forms and reports. You learned that Access searches for this table during startup and that if it finds this table and correct fields within the table , Access loads these custom Ribbons into memory. In the Conrad Systems Contacts Contacts. After you define custom Ribbons in the USysRibbons table, you can specify that Access load a specific custom Ribbon each time you open the database.
In the Ribbon And Toolbar Options section, click the arrow on the Ribbon Name option, and then select your custom Ribbon from the list of loaded Ribbons, as shown in Figure 24—2.
Note that you might need to close and reopen the database to see any new Ribbon you just created appear in the list. Click OK to save your changes, and close the Access Options dialog box. The next time you open your database, Access applies that custom Ribbon. Figure 24—2: In the Current Database category in the Access Options dialog box, you can select a specific custom Ribbon to load each time you open the database.
To prevent Access from automatically loading any custom Ribbons during the startup procedure, press and hold the Shift key when you open the database. When you dynamically load your Ribbon customization using the LoadCustomUI method, you can store your XML in a table with a different name, in a different database, or in a Visual Basic module.
Syntax Application. If you want to dynamically load custom Ribbons, you need to call the LoadCustomUI method each time you open the database. In the Conrad Systems Contacts project file Contacts. Close Contacts. Next, click the menu at the top of the Navigation Pane, click Object Type under Navigate To Category, and then click Tables under Filter By Group to display a list of tables available in this project file. EOF Application. LoadCustomUI rst! RibbonName, rst! RibbonXML rst. MoveNext Loop ' Close out rst.
The first line of code in the LoadRibbons function creates a new ADO recordset that the code uses to fetch the records from the custom Ribbon definition table. The If statement checks to see whether Access has already loaded customization by verifying whether a cached copy of the RibbonUI has been set.
If the main custom Ribbon has been loaded, Is Nothing returns a value of False to indicate Access already has loaded the Ribbon.
To load the custom Ribbons, the code opens an ADO recordset on the ztblRibbons table, loops through each record in the recordset, and calls the LoadCustomUI method once for each record.
After Access loads each Ribbon, the code closes the recordset and sets it to Nothing. The last line before the End If statement returns a value of True for the LoadRibbons function, indicating success. The last part of the code has an exit procedure and our error handling code to handle the case if Access encounters an error. You could also store the XML directly within a code module and set it to a string variable.
Using Ribbon Attributes The RibbonX architecture contains many controls and attributes you can use in your applications. Open the Contacts. Next, open the frmSplash form in Form view either by double-clicking the form in the Navigation Pane or by right-clicking it and clicking Open on the shortcut menu. The frmSplash form is displayed for a few seconds and then opens the frmSignOn form where you can sign in to the database. Neither of the users has a password assigned.
Access opens the frmMain form and displays the custom main Ribbon for this database, as shown in Figure 24—3. The News group displays three labels, one of which displays the name of the current user signed in to the database. The remaining three groups display custom buttons that allow you to navigate to the various parts of the application. You can see in Figure 24—3 that all built-in Ribbon elements are hidden. As you recall from Chapter 23, if you set the startFromScratch attribute to True, Access hides all four built-in Ribbon tabs, displays limited options when you click the Microsoft Office Button, and displays a limited Quick Access Toolbar.
When you build a custom Ribbon definition, you can either define an entire custom Ribbon or define XML that modifies one of the built-in Ribbons. In your XML, you define custom controls. You assign attributes to your controls to define how they look and where they are positioned, and you define callbacks for your controls to define how they act.
In Visual Basic terms, you can think of an attribute as a property of a control object and a callback as a method or event of a control object. When an attribute of a control is a callback, it is essentially the same as an event property of an Access control-you assign to a callback attribute the name of a procedure that will handle the event. You can also copy attributes of built-in controls by using an attribute name that is a Control ID, and you can reference a control in another custom Ribbon using a Qualified ID.
Defines the text to display an enhanced ScreenTip when the user rests their mouse pointer on the control. In addition to attributes you can use in your XML customization, you can create many types of controls using RibbonX.
Table 24—2 lists the types of controls you can use in a custom Ribbon definition and their associated attributes properties and callbacks event properties. None Note that you must create a button inside a dialogBoxLauncher tag and then use the attributes of that button to specify attributes for the dialogBoxLauncher.
None Note that you must create a button inside a dailogBoxLauncher tag and then use the callbacks of that button to specify events for the dialogBoxLauncher. Now that you know the attributes and callbacks available in the RibbonX architecture, you can begin to study how we created the main Ribbon in the Conrad Systems Contacts database.
If you still have the frmMain form open, click the Exit button to close it, and then click Yes to confirm that you want to exit. Specifies a procedure that processes the RibbonLoad event when Access first displays the Ribbon.
In this event, you can save a pointer to the Ribbon to enable your code to dynamically update it. Creates a new label control, IblWelcome, and specifies the onGetLabel procedure to respond to the getLabel event to dynamically update the text displayed in the label.
Creates a new group with a Control ID called grpNavigation and displays Navigation as the group label. Creates a new button, cmdCompanies, with a label of Companies. The button size is set to large, and the onAction attribute issues a callback to the onOpenCompanies procedure.
Finally, we designate text to display as a supertip. Creates a new button, cmdContacts, with a label of Contacts, an image copied from a built-in control, and a callback defined. Creates a new button, cmdProducts, with a label of Products, an image copied from a built-in control, and a callback defined. Creates a new button, cmdPendingEvents, with a label of Pending Events, an image copied from a built-in control, and a callback defined.
Creates a new button, cmdlnvoices, with a label of Invoices, an image copied from a built-in control, and a callback defined.
0コメント