Garry Robinson's Popular MS Access, Office and VB Resource Site


Home  Contact Us

Order Software

Search vb123

 Smart Access  
The Magazine that Access Developers loved to read and write for is back
Article Index Here or
Purchase Here

RSS & Newsletter  
Join our XML/RSS Newsfeed or sign up for our informative newsletter on Office Automation, Access and VB topics
Sign up here

Get Good Help
If you need help with a database, our Australian Professionals could be the answer
Read More

123 For Office

Great shortcuts, supports Office 2013 to 2003, easy zipping.
Read More

  The Workbench  Find out who has your database open, start the correct version of Access, easy compacting and zip backups, change startup options,  compile, shutdown database
Read and Download

Access > SqlServer 
Upsize to SQL Server 2005 or 2008, easily repeated conversions, highly accurate SQL query
translation and web form conversion.
Read More

Like FMS Products?
Purchase them from us and get a free Workbench or Smart Access  More

Garry's Blog
Find out a few other things that Garry has been writing about Microsoft Access. Read more

About The Editor Garry Robinson writes for a number of popular computer magazines, is now a book author and has worked on 100+ Access databases. He is based in Sydney, Australia
Contact Us ...



Next Tip  Building Your Own Wizard User Interface

by Garry Robinson

One of the most successful user interfaces that Microsoft have created for their products is the Wizard. A wizard is a way of breaking up what would be a complex interface into a series of simple pages. This article concentrates on how you can put together a number of Wizards inside your Access application. Included with the article is a number of Access objects that you can import into your application so that you can build your own Wizards.

Why I Got Into Wizards

After reading Peters Vogels recent articles about user interfaces , I began to ponder how I could make the shareware that I have developed a better experience for users. This includes one form that has over 75 different controls on it. So I decided that I would aim to make the whole system easier and give the users a head start by using a wizard to fill in some of the fields on the form. Then I decided to build more wizards for other activities that were explained in the manual but were unlikely to be used by my shareware audience. At this stage I had to generate a more general way of managing these internal wizards as I didnít want multiple versions of the form that was driving the wizard pages. The end result is that the wizards now act as guides to my software, the software now looks more professional and users are reacting more positively to the software. Maybe the wizard interface can do the same for your software.

NOTE: When building an Access wizard, I use the Access Workbench favorites to switch quickly between the MDA database and a database that tests the wizard. I also store the MDA file in the C:\Documents and Settings\Garry Robinson\Application Data\Microsoft\AddIns folder so that I can debug it and change it quickly. Finally I regularly use the quick backup option in the workbench to make copies during the daya becuase building a MDA wizard is difficult and error prone.

What Is The Wizard User Interface

There is probably no exact definition of what a Wizard UI is but if you look a the Microsoft Examples such as the New Form Wizard you will find the following characteristics

  1. The user is presented with a series of small, uncluttered forms
  2. Each page has a heading and a description of what you are meant to do on each page
  3. Each page asks the user to complete one or two tasks
  4. The bottom of each page will have a forward and back button unless you are on the first or last page
  5. All pages will have cancel button so that you can quit the wizard.
  6. The final page will have a finish button (and so might other pages).
  7. If you hit the Back and Forward buttons, the wizard will remember your previous entries.

8) The fields on the forms will have intelligent default values.

The Wizard Database

To demonstrate how you would go about building your own wizards, I could think of no better example than a wizard which would help you build a wizard. I will call this Wizard WizWiz from now on. At this stage its time for a confession. WizWiz is a modified version of the Microsoft Wizard Building Wizard (see sidebar). The different approach that I took was to assume the design principle that the wizards that this system would produce an Internal Wizards rather than a wizard that you run as an Add-In. The other change that I introduced to WizWiz an extension to easily manage a number of wizards inside the same database. And while I was at it I stripped out some of the code that was used for managing Add-Ins.

So to start the process off, open the download database called WizWiz.MDB. Once you have tested the software, import the all the Tables, Forms and Modules with a prefix of "Z_" into your own database.

Building Your Own Wizard

Open the form called z_Wizard. This can act as your control center for the different Wizards in your application. Now click on the Build Wizard Wizard button and this will display Figure 1



Figure 1 - Getting started with your own wizard


The first page of WizWiz asks you 3 important questions. The first is the identifying code. This is the key that ties all the forms of the wizard together. In figure 1 my identifying code is "Graph" which means that all the forms will be have a suffix of Graph. The "Name" is used for the heading of each page. "Description" will initially be used for all the pages in your wizard. You will change the indvidual descriptions in the system tables later. In figure 1, "Build A New Internal Wizard" is the name used in the wizard and "First You need to give the Wizard a code, a name and general description" is the description.

The next page of WizWiz is shown in Figure 2. Now you are going to give the wizard a prefix that follows your favorite naming conventions. You are also going to specify how many pages your wizard will consist of. Do not be concerned if you haven't made a final decision on the number of pages. As the wizard system is table driven you will be able to alter your selections later on.

Figure 2 - Establishing the names and number of pages that your wizard is going to use

In the example that I have shown, I have asked the wizard to generate 3 pages using a page prefix "My_Wizard". This means that WizWiz will generate forms called My_Wizard1_Graph, My_Wizard2_Graph and My_Wizard3_Graph.

Now click on the next button and you are presented with the final page as shown in figure 3. Here you fill in your company details, the version number (where 130 = version 1.3) and the year that your wizard was built.


Figure 3 - Completing The Build Your Own Wizard Wizard


Finishing Off

When you click on the Finish button, WizWiz will then copy a form called z_WizPage_Template and make a new page for the full sequence of pages requested. WizWiz also adds a number of records to the system tables which are called z_wizPages and z_WizInfo.

The Template Page

If you wish to add your own logo and modify the layout of the template, you should do this before you start. WizWiz has been setup in such a way that you can modify the template page to suit your own wizard requirements and the next time you run WizWiz, your new pages will reflect your changes.

How Does Your New Wizard Work

The wizard comprises of one key form called z_WizPage_Main and an accessory form called z_WizPage_help. The main form has the Wizard Help, Cancel, Back, Forward and Finish buttons on it and all the supporting software to drive the internal pages for your wizard. When you start up the wizard, you would use the following open form statement to startup the wizard that we just completed where Graph is identifying code

DoCmd.OpenForm "z_WizMain", _

acNormal, , , , , "Graph"

The Form_Open event starts calls the internal pages of the wizard through a unbound subform control as follows

wzCurrent = Me.OpenArgs

wzPrefix = vGetuzInfo(0, 1)

wzName = vGetuzInfo(1, 1)

This vGetuzInfo subroutine will retrieve a record set from the z_WizInfo table using a query as follows

SELECT * FROM z_WizInfo WHERE wizcode = '" & wzCurrent & "' and Key = " & intKey

So from our previous example, we would open up the first wizard page called My_Wizard1_Graph using code in the Form_Load Event.

Me!frmPage.SourceObject = wzPrefix &_

intWhatPage & "_" & wzCurrent

Setting Up The Buttons

All the buttons are made active or not using a subroutine called SetupNavButtons. This function works using recordsets based on the following query

SELECT * FROM z_WizPages WHERE wizcode = '" & wzCurrent & "' and PID = " & intWhatPage

So the buttons are turned on and off according to the following table of possibilities.

All the buttons are made active or not using a subroutine called SetupNavButtons. This function works using recordsets based on the following query

SELECT * FROM z_WizPages WHERE wizcode = '" & wzCurrent & "' and PID = " & intWhatPage

So the buttons are turned on and off according to the following table of possibilities.































Table 4 - The button combinations that you can set for your wizard.

So open up the system table called z_WizPages and look at the buttons column for rows with a WizCode of "Make". As WizWiz is a 3 page wizard, e have a Next button on the first page, Next and Back on page 2 and Back and Finish on page 3. WizWiz will setup your new wizard using the same button sequence. Whilst you are looking at this table, the column Heading is what appears at the very top of each page whilst the column Text is the description that appears on each page.


What Makes The Buttons Work

Now the wizard will display your first page and display the buttons. How does the software run code under each button for a series of unbound forms ? Well the answer is through form methods and in each of the pages you will find a series of functions called GoNext, GoBack and Go Finish. One of these is shown

Function goNext()

goNext = True

end function

This public Function is called from the form z_WizMain and then the new page has its buttons turned on and off as appropriate.

Set frmCurrentPage = Me!frmPage.Form

If frmCurrentPage.goNext() Then

intWhatPage = intWhatPage + 1

Me!frmPage.SourceObject = wzPrefix & _

Format$(intWhatPage) & "_" & wzCurrent

Call SetupNavButtons

End If

I also added a method called showHeadings which will allow you to pass the heading and description of the page to be displayed on the unbound form.

Adding Your Own Code To The Wizard

All of the above was background material and was mainly designed to give pointers to the inner workings of your new wizard. What you really need to know at this stage is how you would add you own controls and code to start making your wizard work. If you look at Figure 1 again you will see that there are 3 fields that need to be filled in by the user. You may at this stage open the form z_WizPages1_Make in design mode and look for the function GoNext. As we are heading off to the next page, we need to store the entries to the fields on the screen. For programming simplicity, I have used a public array variable call wzVariables. This as with other shared public variables are stored in the Module "z_Wiz". So the user entries are stored as thus

wzVariables(1) = Me!txtCode

wzVariables(2) = Me!txtName

wzVariables(3) = Me!txtDescribe

And if the user returns to the current form using the Back button you need to check if the variables have been used and show them on the screen using code as follow.

If Not IsNull(wzVariables(1)) Then

Me!txtCode = wzVariables(1)

End If

You also need to write a little bit of the same code on the goback function of each form to save any current entries. As these are global variables, it is a good idea if you clear them when starting up the wizard. A function called ClearWzVariables will do this for you.

The Finish Button

To complete the whole process you need to write the actual software that the wizard is going to perform under the Finish function on the last page in the wizard sequence. Have a look at the form called z_WizPages3_Make where you will see all the code that builds your wizard pages. I have included some snippets below

Set rstWizPages = CurrentDb.OpenRecordset _

("z_WizPages", dbOpenTable, dbAppendOnly)

' Now we need to loop through the total number of pages required and

' make the new templates

For i = 1 To wzVariables(5)

newPage = wzVariables(4) & i & "_" & wzVariables(1)

DoCmd.CopyObject , newPage, A_FORM, templateName

With rstWizPages


!PID = i

!wizCode = wzVariables(1)

!heading = wzVariables(2)

!Text = wzVariables(3)

If i = 1 Then

' Setup the forward button

!Buttons = 2

ElseIf i < wzVariables(5) Then

' Setup the back and forward buttons

!Buttons = 3


' Setup the back and finish buttons

!Buttons = 5

End If


End With

Next i


If you are going to put the Finish button on more than one page, you will have to make this a public routine.




Wizards are a very legitimate user interface that can be used in your applications for complex tasks or for setting up complex forms. As Access programmers, you are probably far more aware of them than your users who really only want to learn the minimum to get there job done. Bearing that in mind, you can certainly enhance your software by using WizWiz to make professional looking wizards. As a rule they take a bit longer to program as you have to coordinate a number of forms together to make an interface. But if they replace user manuals for the same tasks, it could be easily argued that they will be cost effective to produce. So make sure that they are appropriate for the task at hand and abracadabra.


Other Smart Access Articles

Helen Feddema "Building Add-Ins and Wizards" in July, August and September of 1998 in the Smart Access magazine 


Side Bar - The Microsoft Wizard Builder Wizard

Tucked away in the bowels of the Microsoft site is a wizard that will set up a number of different styles of Wizards. The first is an Add-In builder and the final outcome is formed the starting blocks for the software in this article. The second wizard is a database objects builder which will allow you to setup tables, queries, forms and reports. The final one is a Property/Control Generation and Editing Wizard. I have used this a number of times and whilst the result is pretty good, you have to be very careful with the Entry Point Arguments. At this stage either refer to Helen Feddema's articles or tip toe through your registry to see what was set by the Microsoft Wizards.

To find this download, go to


Then look for MS Office then Access

If you get stuck, you can download the readable MDA versions of the Microsoft Wizards from the same page and try and figure out their tricks for the different types of wizards. Or better still buy an Advanced Access Book.

  Click here for the download file if you own "The Toolshed"  Else ???   


Author Bio.
Garry Robinson is the founder of GR-FX Pty Limited, a company based in Sydney, Australia. If you want to keep up to date with the his latest postings on Access Issues, visit his companies web site at http://www.gr-fx.com/ or sign up for his Access email newsletter here Contact details Ö
www.gr-fx.com +61 2 9340 7789

Other Pages On This Site You Might Like To Read

FX Wizards - A series of Access wizards to help your productivity.
Microsoft FreeStuff
Consolidation Queries
Making Microsoft Graph Work Better Better In Access using Visual Basic

Samples of Menu and Toolbar Protection

External Links

How to Programmatically Create, Search, Replace, and Modify Code

The Demonstration Database

The demonstration database would suitable For Access 97, 2000 and maybe even 95 and 2 with a bit of code cutting.  The download files are available as part of "The Toolshed"

This article first appeared in the December 1999 Edition of Smart Access. You will find this in the Bronze collection of Smart Access   (http://www.vb123.com/smart).

and was written by Garry Robinson from GR-FX Pty Limited

Click on the following button Next Tip to jump to the next page in the document loop.

Links >>>  Home | Search | Workbench | Orders | Newsletter | Access Security | Access professionals