Weird Report Behavior with Access 2003 Report

W

Wesley Wildman

Context: Windows XP SP2, Access 2003

Problem: The same report appears differently when I open it in print preview
mode from a macro versus when I open it in print preview mode from code. The
difference is that a particular control is not displayed when opening the
report from code.

The Trick: The problem only appears when I impose a Where clause. If there
is no Where clause, the report opens fine both ways. When there is a Where
clause, the control drops out, but only when the report is opened in code.
The Where clause limits dates in the underlying recordset and has nothing
directly to do with the field underlying the control that disappears. The
particular dates in the Where clause don't make any difference to the
problem. Opening the report to print rather than print preview also makes no
difference.

The code (couldn't be simpler):
Public Sub junk()
DoCmd.OpenReport "rptJunk", acViewPreview, , "DateKey1 >= #10/24/2000# AND
DateKey1 <= #6/30/2003#"
End Sub

Whining: How can using a Where clause in code cause this behavior? Can
someone suggest a workaround? I have already tried the obvious, including
compact & repair, starting the application using the /decompile switch, and
creating a new form and importing all of the elements into it. I have not
tried creating a brand new front-end database; there is no sign of corruption
in any other facet of the database operations.

Appeal: I am hoping someone already knows something about this weird behavior.

Thanks, Wesley Wildman
 
Top