dB2K Novice Notes
An Example of Preview.WFM and Report Parameters
by Steve Hawkins

February 14, 2001
Author's note: The scope of this document is limited to providing a review and example of how I put Ken Mayer's PREVIEW.WFM report viewing utility to use. Included is an example of passing parameters to a report either by directly printing or by using PREVIEW.WFM. It is assumed that you already know how to create forms and reports. If you are not at least a little familiar with the Report Designer, queries and rowsets, and object oriented concepts, please first review the knowledgebase files on these subjects, located at the dB2K website. I would also note as a disclaimer that some of the code used in this document was 'borrowed' from others on the dB2K newsgroup. A sincere thanks to all of the folks there.


Introduction
dB2K offers a built in "ReportViewer" class which is defined in online help as "A control to display a report on a form". It does what it says and will display a report (.REP file) on screen. It is not horribly functional on it's own though and putting it to proper use requires some enhancements. To make life easier for us, Ken Mayer created a form called PREVIEW.WFM.

PREVIEW.WFM uses a ReportViewer object and allows reports to be viewed on-screen. It also provides pushbuttons for printing and traversing pages and even allows for passing parameters to your report. PREVIEW.WFM is among the many helpful, useful and downright handy pieces of dB2K code contained in the dBASE Users' Function Library Project (dUFLP). The library is available for download from Ken Mayer's web site

As a novice dB2K user, I had a difficult time making my reports work with the PREVIEW utility when I wanted to pass parameters to the report. Then, one day, I finally "got it". Since others had many of the same questions as I, it seemed worthwhile to post an example. Please keep in mind that I am a novice. This is my way of doing it, but better ways may exist. I hope you find the examples helpful.

What I wanted to accomplish
I am re-writing an old DOS application designed to keep track of video tapes for a video rental store. The data and the reporting needs are fairly simple. I wanted the user to have the following options:

The user dialog for making the selections is started by way of a menu selection and looks like this:


To see a sample PREVIEW form (from clicking the "Screen" button), click here.

To handle the pushbuttons, I only had to create four methods for this form.