Welcome to MSDN Blogs Sign in | Join | Help

Microsoft Access Team Blog

Get product announcements, tips and tricks, and news directly from the team @ Microsoft.
A Tool for Building Custom AutoFormats

In the last post, I discussed the new AutoFormats in Access 2007.  In this post, I'll describe more about how they work and provide a tool that allows you to create your own formats and customize the ribbon gallery of formats.

AutoFormat Storage

Access 2007 stores AutoFormat information in two different locations, depending on whether those formats have been customized or not.  Un-customized formats are stored in tables in an Access 2007 format database that is installed with Office and is shared across all users who have no customized AutoFormats.  The file is located at:

    %PROGRAMFILES%\Microsoft Office\Office12\ACCWIZ\ACWZUSR12.accdu

If a user has used the AutoFormat Wizard to add, edit, or delete an AutoFormat, then Access will create a copy of the AutoFormat file for that user.  From that point on, all AutoFormat data for that user is stored in their personal database, which is at:

    %APPDATA%\Microsoft\Access\ACWZUSR12.accdu

This is a similar scheme to the way AutoFormat information was stored in Access 2003, but the table schema has changed for Access 2007 formats, so it is not possible to reuse a version of the 2003 database to retain existing AutoFormat settings.

AutoFormat Functionality

The AutoFormat engine works by applying a single format per control type per section.  This means, for example, that all the textboxes that appear in the details section of a report will get the same background color, font face, etc. as one another, but that these settings may all be different than the textboxes in the Header or another section.  The AutoFormat database simply lists all of the property settings for each of the control types for each of the sections.  There are four key tables in the database for these settings, along with other tables for things like supporting functionality, localization, and support for other features.  They four key tables for formatting are:
  • tblStyles - this is a top-level style listing, normalized to style level data like the name of the style and the picture to display.  Note that pictures are stored in the Access internal "Picture Data" format which can be set and retrieved using the PictureData property on images or form and report objects.

o   tblSectionStyles – Each style has a list of section styles, being the appearance for each section (page header, detail, form footer, etc…).  Formats included here are section background color and alternating background color.

§  tblControlStyles – For each section, there is a list of control styles, with 0 or 1 entries for each control type.  Control styles have the bulk of the interesting formatting to do with text, like Bold, Italics, Underline, as well as shape appearance, like Border Color, Back Style, Special Effect, etc…

§  tblLayoutStyles – Formatting for layouts is also specified on a per-section basis.  There can be 0 or 1 format entries per section for both Stacked and Tabular layouts.  Layout formatting is mostly to do with gridlines.  For example, all stacked layouts in the detail section can have a ‘Both’ grid style, while all Tabular Layouts have the ‘Vertical’ style.

AutoFormat Editing Tool

The format of these tables inside the database was never meant to be human readable, and can be pretty terse to browse.  To make life easier for our own internal editing, we assembled a little tool (an Access database, of course) for viewing, adding, and editing AutoFormats for a given instance of the Acwzusr12.accdu file.  If you would like to play around with AutoFormats a little bit, this tool will make that easier.  Keep in mind that this is, something we just threw together to work with the rather complex AutoFormat data more easily.  The code is pretty rough for a sample, without extensive comments or robust error handling, but it works well for reading and editing AutoFormat data, and what’s more, the tool contains updated AutoFormat data with a number of bug fixes we’ve made since Beta 2.

The tool is available here and is a 2m zip file, so will take a little while to download.  This tool will also be part of the Access 2007 Developer Toolkit and will be both polished and contain the final AutoFormat settings at that point.  The file simply contains an Access database, which you can save to your machine and open.  You'll need to either save the file to a trusted location on your machine or manually enable VBA for the file to work. 

Opening the tool brings up the following dialog:

(Click image to enlarge)

Clicking the first link "Step 1:  Add / Edit AutoFormats" brings up a large dialog with a list of all of the formats and each of the settings for each of those formats:

(Click image to enlarge)

This is just a standard Access form, so you can filter or sort it as necessary.  There is a separate record for the both the Form and Report settings for each format, and then each of the settings for each control and section is laid out below.  The AutoFormat property called "Gallery Index" at the top determines where this format goes in the AutoFormat Gallery shown in the last post.  This doesn't update the picture in the ribbon (to do that you need to update the ribbon XML file, which we'll cover later) but this is an easy way to get your format on the ribbon. 

After you have updated the styles as you like, including adding or deleting any additional styles, you'll need to regenerate the AutoFormat tables.  The first setup is to click the compile button, which runs a series of queries and repopulates all of the AutoFormat tables:

You can optionally then preview the styles, with some built-in UI.  This is less of a visual preview and a set of reports to allow you to verify all the settings:

(Click image to enlarge)

There is a report that verifies that there are no missing styles, which you can access by clicking the Verify button:

At this point, the AutoFormat database has been rebuilt, and you simply need to publish it to the correct location on your machine.  You can do this from the initial dialog.  First you click the Browse hyperlink to set the file's location (this should be defaulted for you, and all you have to do is click OK).  Then click Publish and you're done.

(Click image to enlarge)

Next Time

The next big post will be about using the new Data Collection feature to add or update data through emailed forms.  Those forms can either be plain HTML that work on practically any email client or InfoPath forms that provide a great user experience for Office 2007 users.

Posted: Tuesday, June 20, 2006 10:45 AM by Erik Rucker

Comments

rmcgaffic said:

As attractive as the Access 2007 windows forms appear at first glance, I see a major shortcoming to their use by developer types: they do not support multiple text boxes on the same line, resulting in bloated forms and waste of screen real estate.  While the layout can be removed, you do so at a total loss of all gridline properties such as color, width, and style.

Does anyone know a workaround to this problem or know that Microsoft is going to address it.  Unless this problem is corrected, all the new functionality is useless to me.  Or is this like the Access 2003 tab control, where every back color is available as long as its beige!

Access 2007 permits this, where [  ] is a text box:

Address line 1: [                                       ]
City:                [                                       ]
State               [                                       ]    
Zipcode           [                                        ]

The Access Layout does not support this:
Address line 1 [                                        ]
City                [                                        ]  
State / Zip      [                            ][         ]

The access layout does not support this:
Address line 1 [                                         ]
City                [                                         ]
State              [                ] Zip [                ]
 
How can we retain the use of gridline properties and use multiple text boxes and labels on the same line?
# June 23, 2006 2:27 PM

clint Covington said:

>> How can we retain the use of gridline properties and use multiple text boxes and labels on the same line?

Sorry this isn't supported. I think you will find Layouts are far more useful in reports when you want to add, delete and resize columns.
# June 24, 2006 12:58 PM

rmcgaffic said:

Thanks, Clint for the information.

I am a little surprised that form layouts are not a significant intended use of the layout.  Almost all the illustrations on this blog are forms, and not reports.  If this version is to have serious acceptance by developers, Access 2007 must allow 2 or more text boxes per line.  

Take a look at your own examples on this blog.  The very attractive layouts made possible by gridlines are simply impossible with border properties.

Here's a workable alternative: Give both the label and text box controls for each of top, bottom, left, and write for:

Style
Weight
Color

Some of us would like to replicate the absolutely beautiful UI of SAP Business One, and Microsoft is sure isn't helping.
Please read last week's front page story of Wall Street Journal about effort SAP is taking to get user GUI right.  I only wish Microsoft could be this conscientous.

Again, thanks for the info.
Bob
# June 25, 2006 3:51 PM

Clint said:

Thanks for your feedback Bob. We did do a fair amount of stuff to make it possible to build beautiful UI (tranparent images, anchoring, tabs, Dib, new themes, attachments, etc). There sure is more we can do in the next version.
# June 27, 2006 8:27 PM

Francis said:

Off-topic but still--

When will Access have:
1. select all in SQL view (CTRL+A does not work)
2. find & replace in SQL view
3. syntax/code highlighting (by color, like in Excel's formula bar, so that we can see which open and closed parentheses belong together, what is an SQL command vs. reference to a table/field, etc.)?

It would be nice if Access' could at least hold its own against Notepad.
# June 29, 2006 1:50 PM

rmcgaffic said:

I heard on CNN this morning that Office 2007 release has been delayed.  This really is a blessing in disguise.  I am finding so many bugs in Access 2007, that I would rather report as many as possible and get them fixed rather than suffering through a bad release.

Here's the latest:

Select any object on a form, right click, then click on Properties.

One of three things happen:

1.  The properties sheet pops up on the right side of the screen as expected and all the object's properties are listed and available for modification.

2.  The properties sheet pops up on the right but it is completely blank space.  No listing of individual properties or their current settings is visible.  There is nothing to change.

3.  If the screen already had a properties list as described in 1 or 2 open, clicking on another form object, then observing its properties causes the property list to CLOSE (and not show the new object's properties) and the repaint the form so that it extends to the far right of the screen.  

Numbers 2 and 3 must be fixed.  
# June 30, 2006 8:41 AM

Micah Rousey said:

These changes sound great.  Report formatting has always been a lengthy process in Access development, and hopefully, this will save some time.  (Although I only see it saving time on solutions where the reporting requirements are fairly extensive.)  I'm just hoping the small system, with 5 or less defined reports, won't take longer to develop now with potentially more complex set-up.

# June 30, 2006 4:30 PM

Clint said:

rmcgaffic,
Did you have beta 1 on your machine? I have seen this in cases where people upgrade a beta 1 machine to beta 2.
# June 30, 2006 6:00 PM
New Comments to this post are disabled
Page view tracker