Dialog Form for filtering report

O

oldblindpew

I have a custom dialog form with an unbound list box, an option group, and
some check boxes, by which the user configures his report. There are command
buttons for Preview and Print. The user clicks the various controls on the
dialog box, then click Preview. If he doesn't like the result he closes the
preview, and clicks few more boxes in the dialog form and previews again.

I must be needing some kind of requery because once certain records are
filtered out, they won't come back just by rechecking the appropriate
checkbox. The dialog form has to be manually closed and reopened to get
everything reset.

I hate to beg help again, but here's another of those "simple" questions
that won't seem to yield to a bit of simple research.

Thanks,
OldBlindPew
 
D

Duane Hookom

You stated you "he closes the preview". I believe you need to close the
report completely.

Generally, I have a filtering form that I open first. Users can then set the
various criteria and click a button to preview a report.
 
O

oldblindpew

I'm using DoCmd.OpenReport to run my report, in acViewPreview mode. I'm not
sure what my procedure is doing while the report is being previewed,
presumably either pausing or exiting. When the user finishes previewing the
report and clicks the "Close" button at the top right, I can only assume the
report is closed at that point.

I tried inserting the following line of code after my DoCmd.OpenReport
statement:

DoCmd.Close acReport, strReportName

but this just results in the report being closed immediately after opening,
so you never get a chance to see it. This would seem to indicate that
execution is not paused by DoCmd.OpenReport.

So I'm pretty much out of ideas at present...
 
D

Duane Hookom

Are you opening the report before the form opens? If so, my suggestion is to
change this so the form is open and a button on the form runs
DoCmd.OpenReport.
 
O

oldblindpew

I'm sorry, I thought I'd made this clear. I have a form with command buttons
for Print and Preview. User makes selections on the form, and an On_Click
event procedure evaluates the form and ultimately runs DoCmd.OpenReport.
After looking at and closing the preview, you end up back at the form again.
 
O

oldblindpew

I've figured this out, at last.

I was making the perfectly reasonable (to me) assumption that check box
values would be either 1 (checked) or 0 (unchecked), or null. My check boxes
were of course unbound, if that matters, and I was specifying default values
of 1.

Leave it to Access to overcomplicate things and be at once too smart and too
dumb. Access had no problem with my default values. Later I found out by
trial that you can use almost anything as a default value for a check box,
and it will seem to work okay, e.g. "1" will result in a checkmark, and "0"
wil be unchecked, but you can still get the checkmark using -1, 2, True, or
=True, and for all I know a host of other values. (BTW, I could not find a
discussion on this in Access Help or in my reference books. It's probably
there somewhere, but actually finding it is another matter).

I was even able to reference these bogus-valued check boxes in my procedure
and perform my tests and If statements on them. The problem came when I
closed the print preview and returned to the form, and for the first time
used the mouse to recheck boxes, rather than relying on Default Values. Now
some of the check boxes had values my code was not expecting, so my tests
begin to fail logically. I never got any compile errors or warnings to clue
me about the real source of the problem.

I changed all my default values to either True or False, and changed my code
to test for these values, and now things appear to be working okay.

OldBlindPew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top