Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Tips Database Forum Rss Feed

» Database Journal Home
» Database Articles
» Database Tutorials
MS Access
SQL Scripts & Samples
» Database Forum
» Slideshows
Free Newsletters:

News Via RSS Feed

Rss Feed

Database Journal |DBA Support |SQLCourse |SQLCourse2

Featured Database Articles


Posted Jan 13, 2009

Access forms and DB2 Data Server - a perfect match - Page 2

By Paul Zikopoulos

The Design view: more complex, but more powerful...

In the previous section, I showed you how to create a simple and quick form. In case you need something more sophisticated, the Design view gives you more programmatic control over everything in your form including sizing, binding, and image layout.

Of course you can create a form from scratch using the form designer (select Create>Form Design from the Office ribbon), but let’s take the form we already have and work with it in the Design view. I recommend this approach to form building: start simple and hand-tune the form with added complexity until you get the form you want.

To change to the Design view, right-click in your form’s white space and select Design View:

As you can see in the previous figure, the Design view gives you a lot of manual control over your form.

For example, in the Form view you can’t change the default size of the column labels (or their names, for that matter). You might have tables in your database schema with some pretty odd names. (Believe me, I’ve seem them all, especially with packaged applications.) I showed you earlier in this series how to create object abstractions with customized table names, but you may need to address column names as well. For example, if the form you are building is for data entry in a country where English isn’t the native language, you may want to avoid short forms such as DEPT for DEPARTMENT or COMM for COMMISSION. Using the Design view, you can override the default names. For example, click the DEPT label and change the text to DEPARTMENT as follows:

Using the Design view, you can override the default names

Note: The formatting and techniques discussed in this section also apply to other text or numeric objects, such as the actual data columns on the form. For simplicity, I’ll just focus on formatting labels.

The nice thing about customizing the label is that Access automatically resizes all the labels aligned with the changed label such that they are big enough to accommodate the largest label. What’s more, Access automatically keeps the binding of the field beside the label to the underlying data source, so you don’t need to do anything more than make the form look the way you want it to look. Now click the COMM label and change the text to COMMISSION so that labels in your form now look like the figure below.

Access automatically resizes all the labels

Access also gives you control over the labels (and other objects) and how they will appear. For example, to apply styling preferences to your labels, simply select the labels you want to change (use the Shift to perform multiple selects), right-click, and select a formatting option:


apply styling preferences to your labels

In this example, I chose to shadow the labels. As you can see, you can adjust font and fill colors, and more. The best way to learn about these options is to experiment with them yourself; this article is just designed as an introduction into the options you have when working with DB2 data in Access.

the View drop-down list

Tip: You can use the View drop-down list in the Office ribbon to quickly switch between the Form view and the Design view to get a more “end-user look” at your form as you customize it.


After experimenting a bit with my form in the Form view, I made it look like this:

sample form

You may be wondering how I was able to get all of these widgets and controls on my form. It’s outside the scope of this article to delve into the details of formatting in Access; rather, I’m just trying to give you some areas you can explore with our DB2 data. So I’ll just say that in the Design view, you can use the Design tab in the Microsoft Office ribbon to add various controls and widgets to your form.

use the Design tab in the Microsoft Office ribbon to add various controls and widgets to your form

The following figure shows some of the different widgets I used to create my form; note that the Properties Sheet can be used to specify properties for each of the widgets on the form:

The Layout view: getting it just right

The final view that you should know about when working with Access forms bound to DB2 data is the Layout view. You use this view to work with non-programmatic finer details of the form, such as adjusting font sizes and colors, applying pre-defined stylesheet templates to our form and more. Much like the Design view, the Microsoft Office ribbon has a number of controls that relate to the layout and display characteristics mentioned earlier:

As you can see, you have a number of formatting options. The AutoFormat section of this ribbon is especially powerful; you can take your forms from the drab to the fabulous with the click of a button:

The AutoFormat section

You can also use this view to apply conditional formatting to your DB2 data on the client side:

Wrapping it up

In this article, I showed you how to create a form in Microsoft Access 2007 and bind it to data stored in a DB2 data server. In addition, I showed you how to place programmatic controls on your form and format it for a sharp visual affect, and more. In my next article, I’ll describe related features such as split forms, multiple item forms, a pivot table form, a data sheet form, and the form wizard to make the generation of forms even easier.

» See All Articles by Columnist Paul C. Zikopoulos


IBM and DB2 are trademarks or registered trademarks of International Business Machines Corporation in the United States, other countries, or both.

Microsoft is a trademark of Microsoft Corporation in the United States, other countries, or both.

Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both.

Other company, product, or service names may be trademarks or service marks of others.

Copyright International Business Machines Corporation, 2008.


The opinions, solutions, and advice in this article are from the author’s experiences and are not intended to represent official communication from IBM or an endorsement of any products listed within. Neither the author nor IBM is liable for any of the contents in this article. The accuracy of the information in this article is based on the author’s knowledge at the time of writing.

DB2 Archives