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.
Better Looking Forms & Reports, Faster

Building modern looking data forms & reports in Access 2003 can be difficult.  Doing the heavy lifting is easy - there are great tools for building the data-bound portions of the form - but making the interface look great can be a challenge and can require some creative hacks.  UtterAccess even has a popular board devoted to helping people build better looking interfaces.  In Access 12, we've built a number of features that will help people build great looking apps with far less code, time and effort. 

Better Image Support

We did work to improve native support for image formats. In the past, you could add pictures but there were some serious limitations. First, when the picture was added it was converted from its native format to a device independent bitmap (dib). This resulted in significant bloat if the image stored data in a compressed file format such as gif and jpg. Even worse in many cases, when the image was converted transparency was lost.

Access 2007 now supports BMP, GIF, JPEG, Exif, PNG, TIFF and DiB without bloating the database size. Images with transparency work great.  You can see how we're using transparency below - the buttons are all transparent, as is the image in the title bar.

To ensure that database are backwards compatible, we created a new database property called “Preserve image format.” This property controls if the image is converted to a dib or stored in its native format. ACCDB databases default to storing images in their native format while MDB and ADP database Access 2007 will continue to convert images to DiBs so that the image is available when the form is used by older versions of Access. In a nutshell—if you want your image to be displayed in previous versions of Access make sure preserve image format is set to false. I recommend turning off the property if your app is deployed as a runtime or in an Access 2007 only environment.

Another painful limitation of former versions was displaying images on a form or report that were stored in the file system. The Northwind employees form had 135 lines of code to make this work. Now the image control can be bound to a UNC path including jpg and png files.

AutoFormats

AutoFormats are a great way to create a consistent look across an application, but the existing themes were looking pretty dated.  In Access 12, there are 25 new themes that you can choose from that will add that final polished look to your application. The Quick Format gallery gives a small preview of the font and color schemes:

Other New Look Improvements

In Access 11 the SizeMode property provides enums for Clip, Stretch, and Zoom. These properties do not allow us to create really small horizontal or vertical images that tile across the header. The 2003 behavior was to stretch the image across the entire form or report. In many cases the right effect is to stretch horizontally. There are now two new enums: Stretch Horizontal and Stretch Vertical. This makes it possible to stretch an image across the header of the form when it is the Picture property on the background of a form or report.

We also did work to make the grid control more modern and remove the Windows 95 3-D look. Internally, we draw the grid colors from the exact same color palette as Excel.

A few weeks Deano asked about tab controls:

“Also will tab controls blend correctly when you change the colours?  I use Access 2000 and there's a section in the top-right of the tab control that does not match the changed form colour.”

I’m pleased to say that the color now matches the form color. Here is a screen shot from WinXP:

We made a one change to buttons that I think folks will find useful. There is a new enum for backstyle called Transparent and a new property called HandOnHover. Using those two properties and you can create buttons that look like hyperlinks. BTW – have you seen the Vista buttons? I think they look great in our shell.

Cyrus asked about pixel drawing problems on disabled images. This problem has been fixed in builds after beta 2 if preserve image format = false. We remove all the color from the image. 

There is still a some button work we want to consider in the next version. Cyrus—we hear you on button background colors and images and text. Another thing we wanted to do this version but didn’t get to was color properties for different mouse over states.

New Attachment Data Type

If you want to store images directly in the database—the attachment data-type and control works great. In the past users would use the OLE Object data type. Because of how OLE worked there were bloat issues as it had to store a preview of the file along with the OLE data. Attachments are a new complex data-type that stores multiple attachments to a record in a binary field in a hidden table. We compress the file when it is added if it isn’t already a compressed file type. Here is the dialog to manage attachments:

When the image has focus there is a helpful floating toolbar that allows you to navigate through records and launch the dialog.

There are three display as enums: Paperclip, Image, and Icon. The icon will always show up as a paper clip in datasheet view.

Attachments are exposed in QBE similar to other complex data forms. Users can query for the collection or the expanded version returning a row for each attachment. Let me walk through an example with a simple issues database with one record that has 4 attachments. The query designer exposes three columns that are stored in the hidden complex data table: FileData, FileName, and FileType. Double clicking on the root Attachment node will add the attachment collection to the grid below.

               

This generates the following SQL:

SELECT Issues.Title, Issues.Attachments

FROM Issues;

The query returns the collection of Attachments.

If you add the Attachment.FileName to the query you get the expanded results set. Here is the SQL:

        SELECT Issues.Title, Issues.Attachments.FileName

     FROM Issues;

The datasheet now returns the expanded results:

The collection is exposed through DAO so that you can modify and update it. Here is a short code sample:

Private Sub cmdAddImage_Click()

Dim rsEmployees As DAO.Recordset2

Dim rsPictures As DAO.Recordset2

Set db = CurrentDb

 

' Get the parent recordset

Set rsEmployees = Me.Recordset

 

'Put the parent record into edit mode

rsEmployees.Edit

'Get the attachment recordset

Set rsPictures = rsEmployees.Fields("AttachmentCell").Value

 

'Set first attachment to loaded picture

rsPictures.Edit

rsPictures.Fields("FileData").LoadFromFile ("C:\FileName.jpg")

rsPictures.Update

MsgBox "Picture added"

 

' Update the parent record

rsEmployees.Update

End Sub 

The attachment data-type is available in ACCDB files and link tables to WSS lists. It is not available for MDB and ADP databases. We didn’t expand the 2GB limit for Access databases. If you think you will have lots of data in your app break out the attachment column into its own database and use a link table to join it with the table.

Next Time

In the next big post, I'll look at Filtering and Grouping.  In the meantime, I'll have a smaller post about searching in the navigation pane.

Posted: Tuesday, April 25, 2006 2:53 PM by Erik Rucker
Filed under: , , ,

Comments

Cyrus B said:


The improvements to image handling (and tab control) are much appreciated!  

Also, the attachments type (and the way to manipulate it) looks excellent.  I think this will be a very useful feature to a lot of people.  

The only problem would be that many organisations (my current client included) use SQL Server to store their MS Access data, rather than Sharepoint, so the new attachments functionality may not be useable after all.  That would be a real shame as it looks great.
# April 25, 2006 10:05 PM

Floodguy said:

Are there any improvements planned for the Listbox/Listview control? It would be really helpful if could get a listview control like the one in VS2005. I want a better control over headers, rows, and columns. And coloring perhaps.
# April 26, 2006 4:25 AM

Stevbe said:

Do any of the AutoFormats use system constants so when users change the OS our apps will match or has Office gone so far away from the OS interface with it's own color scheme that trying to match the OS would just look wrong?

Do the AutoFormats use the new fonts?

I have noticed that you are using DAO in your example. Is there an internal shift in the focus on DAO as the preffered data access library instead of ADO and have there been any changes made to DAO?

<This problem has been fixed in builds after beta 2>
Does this mean beta 2 is done and we can, hopefully, expect to see it soon?

Thanks,
Steve
# April 26, 2006 6:21 AM

flavo said:

I see in your example you are using a new method DAO.Recordset2. Do you have any further information on what added functionality/changes that have been made to DAO?

On the topic of ADO/DAO, can we now bind mdb Reports to ADO recordsets.  It works fine for Forms/Comboboxes/Listboxes currently, but not Reports :-(  This is a real pain when using ADO to connect to SQL Server (not linked tables).

Dave
# April 26, 2006 7:52 AM

Mark Jones said:

I must say the interface improvements do look great. It's these sorts of details that, like image handling, can mean the difference between a product that flies and a Spruce Goose!

Apologies if this has been answered before, but you mentioned database bloat; have there been any improvements to this perennial problem. Already large daatbases can grow by 10 times or more, if there is enough processing going on. It's at its worst while coding...
# April 26, 2006 11:45 AM

AL said:

These features look truly great.  Do I understand correctly that we ADP developers won't be able to use the new transparent picture features for buttons etc???  OR did you just set the *default* to DIB, but the feature is still available for ADPs?

I can understand how difficult it would be to create a working ADP attachment system without playing with the guts of SQL Server, but...  it would be really great if Access had built-in functions to compress and decompress binary data (pictures, documents, etc) for storage in image fields (ACCDB or SQL Server).  It's a major pain at present to handle this manually - takes quite a bit of code dealing with compression of binary streams or disk files, and other developers would probably not be able to decompress the data.  If it was built into the Access object model, then everyone could benefit.

It would also be great if that nice little paper clip field and dropdown selector box was available in ADPs, so we also could use it to manage (manually-handled) attachments.

(In general, it would be really nice if we could have unbound (and bound) columns in the datasheet view, where we could put row-specific pictures, icons, text, etc.)
# April 26, 2006 12:09 PM

AdamB said:

I mentioned it in another post, but the ability to do attachments in an ADP would be truly amazing. Now that SQL Server 05 has the varbinary datatype it is even more usable.

If you are using a separate hidden table for storing the attachments, I wonder what would prevent you from doing the same thing with SQL server? I assume in your hidden table you are storing just the binary form of the file anyway?

I am probably oversimplifying it, but here is some pseudocode:
if (not exist hidden_attachment_table)
{
 create_hidden_table(); // regardless of whether this is an access db or sql db.
}

Adam
# April 26, 2006 12:13 PM

Eric DB said:

Love the GUI improvements. I lurk on that UtterAccess board often, and have implemented a handful of their suggestions. Glad to see the enhancements to what I can do right in Access.

And, while I'm dreaming about new features: could we create their own color schemes and save them external to Access? (import them in another DB, share with others, etc.).

I agree with an earlier comment about list boxes & VS2005. Drag and drop anyone? Maybe that's already on-deck and I've overlooked it...
# April 26, 2006 6:35 PM

Stevbe said:

Eric DB ... this should help with the color schemes ...

http://blogs.msdn.com/access/archive/2006/03/23/559111.aspx#580594

as for sharing with others ... you can use the hidden functions (right click in the object browser and check the 'Show Hidden members) SaveAsText and LoadFromText to create a text file of the form you are using to to create your custom AutoFormat from.

Steve
# April 27, 2006 9:56 AM

Erik Rucker said:

Thanks for the comments, here's a consolidated response:

Listbox control improved ala VS2005.  Yes, this would be great, but we weren't able to do this version.

Do Autoformats use system colors?  New fonts?  Yes to the fonts for many of the formats.  The templates match the new Office colors, so they'll look appropriate in Office and will follow color setting across Office.  The existing system color templates continue.

Will new images work in ADP's?  Yes, but you have to turn on the feature (it is defaulted off for backwards compatibility).

Several comments on attachments and ADPs - yes, we agree here and wish we could have done more.  This is a SharePoint symmetrical feature, and the issue is the underlying differences between SharePoint and SQL.  

Is beta 2 done?  Not yet, but we're hard at work on it.
DAO vs. ADO.  In general DAO works better against Access.  There are some scenarios where you need to run ADO, but outside of those, you're likely to get better perf from DAO.  

What changed in DAO?  Primarily the ability to connect to complex data.

Can I bind MDB reports to ADO recordsets?  No, you need to use an ADP to do that.

Is beta 2 done?  Not yet, but we're hard at work on it!
# April 27, 2006 6:49 PM

ADD said:

Will we be able to create and edit tables and views in SQL Server 2005 as we were with Access 2003 and SQL Server 2000?
# May 1, 2006 10:37 AM

Clint said:

Yes. Beta 2 will support editing tables and views in SQL Server 2005 in ADPs.
# May 2, 2006 1:24 PM

ADD said:

Oh my Clint.  You made my week!   We've been strugling with Management Studio since we switched to SQL Server 2005.  This has renewed my faith in Microsoft.  Thank you!
# May 3, 2006 10:04 AM

AdamB said:

"Will new images work in ADP's?  Yes, but you have to turn on the feature (it is defaulted off for backwards compatibility)."

Can you expand on this a little bit? Does this mean that Access makes it easier to use Image fields when talking to SQL server? Where is this feature enabled/disabled?
# May 5, 2006 11:34 AM

Clint Covington said:

There is a property in the Access Settings dialog called Preserve Image Format. If you change that property we store images added to forms and reports Picture property in their native format not the OLE format.

The image control now supports a control source--so you can bind it to UNC paths (provide from SQL Server if you like) and have a form display JPG, PNG, BMP, etc. Binding the image control to pictures doesn't require the preserve image format as there isn't a backwards compat issue. Obviously, 2003 won't display images bound to a control source.
# May 6, 2006 10:51 AM

Liveson Tumbulu said:

This sounds great. However, when creating reports it's a bit cumbersome to include, say, the company logo on all reports one by one. I tried to put the logo on the custom report template and it never appeared on the reports that I later created. Is it not possible to include an image on a report template and it should automatically appear on all reports that are later created based on the template? That would be great!!!
# May 9, 2006 3:44 AM

Floodguy said:

Hi Eric,

another question(s): is the screenshot from an existing database and is it available for download?
How did you managed to line up the header background and the buttons background such a way, that it looks like it is one image?

Thanks.
# May 10, 2006 4:54 AM

Clint Covington said:

Good ideas about the company logo--I will forward the suggestion to the forms/report PM.

>> is the screenshot from an existing database and is it available for download?

You should be able to create both of those forms using the AutoFormats. Our templates will be formatted very similarly.

>> How did you managed to line up the header background and the buttons background such a way, that it looks like it is one image?

They are one image. We are setting the form background image with PictureAlignment=topleft and PictureSizeMode=StretchHorizontal
# May 10, 2006 6:27 PM

Ken said:

I ran into a problem in Access 2003 with a very complex inline IIF statement, (Access could would not allow more than 1024 characters in the design mode)

Has this been changed?  What about the QBE interface in general?  Any changes?  I read that the SQL text editor is pretty much still the same, and was wondering if the same holds true for the QBE interface.

Oh, btw, what do you think about this:

http://www.databaseadvisors.com/gazette/sqlexpress.htm

"Microsoft Moving Away from ADPs in Access Kent Tegels quotes Mary Chipman (who wrote the book) in the SSXE newsgroup as saying that Microsoft are now recommending moving away from ADP based solutions. It looks like this may be an experiment that has not been completely successful which leaves those of us who have implemented these solutions with an interesting support problem going forward. Here is the quote:

However, for new application development, ADPs aren't looking so promising, especially if you are thinking in the Yukon timeframe. A couple of problematical issues are complex data types and CLR assemblies. Tackling these head-on in the ADP UI graphical tools in the next version of Access is a daunting challenge, to say the least.

...and...

FWIW, the Access team has moved away from recommending ADPs as a front-end to SQLS apps over the last year or so, based on several public talks given by team members at industry conferences. If you are contemplating new development with Access as a FE to a SQLS BE, you'll likely be ahead of the game with an efficiently-designed MDB/linked table solution rather than an ADP. "


Thanks  
# May 22, 2006 1:33 PM

Brakerm19 said:

<quote> Nelson—you can create a new ADP or MDB database in the getting started screen by clicking on the builder button to the path property and selecting the appropriate file format. <quote>

Access Beta 2 12.0.4017.1003: Where is this builder button? Create New Blank Database just gives option of where to save this new accdb. Only other items on Getting Started Screen is Microsoft Office Online (templates mostly)

In Access Options there are only a three default format options 2000, 2002-2003, 2007 Beta. Online help gives no information on creating an ADP database project.
# June 3, 2006 12:43 PM

Alexei Marine said:

Will we be able to perform a [full-text] search on attachment data?
# June 10, 2006 10:21 AM

Thomas Radas said:

Hi !

I've installed Beta2 and the tabcontrols behaves same then in the older versions ? Howcan I get the right color on the tabs as in your example?


Thanks Thomas
# July 10, 2006 6:12 AM

Mike said:

Is there a way to enable attaching files via a form that is based on a multiple table query?  I can add attachments to the table containing my attachment field, but not to the field in a query I created that is linked to another table with a primary key.

# January 19, 2007 4:40 PM

Michael Turnquest said:

Does Access 2007 offer developers a means of rescaling or resizing forms where the contents of the form are increased in font and object sizes proportionate to the screen on which it is displayed?

# January 20, 2007 1:48 AM

LaVerne Palmer said:

My problem should be trivial but I have not yet found a solution.  In Access 2003, in a text box in a Report, fonts which display and print correctly in a horizontal box, do not retain their font when the text is selected as vertical.  

Specifically, I recently tranferred an ACCESS 2000 application that has been running for several years on 98 SE  to ACCESS 2003 running on XP Professional.  My first run of client envelopes was useless.  The organization name was designed to be in Script MT Bold and the address etc was in Times New Roman.  All text was in the vertical mode because of the envelope format.  When printed, the fonts for all the text were changed (different font - arial? and larger so that text was truncated , etc.) I tried creating a new application simply with a text box in a report design. I could not find a way to get my desired fonts to be retained when I changed any text box to vertical.

# January 20, 2007 11:08 PM
New Comments to this post are disabled
Page view tracker