"Expression is typed incorrectly..." only when printing

B

Brian

Very strange. I have a report that has a subreport. It previews just fine,
including the subreport, but when I then send the preview to the printer, I
get this error: "This expression is typed incorrectly, or it is too complex
to be evaluated..."(blah,blah,blah)

Then, when the report goes to the printer, the subreport is not on it.

Ideas?
 
B

Brian

....and if I change the printing mode from acViewPreview to acViewNormal, it
prints the subreport without the error. But, I really want the preview. I can
work around this by having separate preview & print buttons, but that is
likely to seem a little tacky to my client.
 
A

Allen Browne

Strange. Not sure what would cause it to fail in one view but not the other.

The error means that Access is not able to understand an expression. One
possible cause is that the data type is being understood incorrectly. If
this is what's happening, you may need to explicitly typecast calculated
fields in the report's RecordSource query, or set the Format property of
text boxes that are unbound or bound to expressions, so that Access
understands the data type. More info in:
Calculated fields misinterpreted
at:
http://allenbrowne.com/ser-45.html

Do you have any code in the report's module? If so, you may need to reset
some module-level variables in the Report Header section's Format event, so
they get reset between previewing and printing. Also, be careful not to
assign bad data types. For example, if you have a numeric value, don't
assign a zero-length string to it, becuase it would then no longer be a
number and any attempt to treat it as a number in another text box (such as
a total) would yield an error.

The fact that it is the subreport that falls off may indicate that the
problem is either in the subreport or its grouping expressions, or perhaps
in the LinkMasterFields/LinkChildFields properties of the subreport control.

It is remotely possible that this is due to a faulty printer driver. You
could test this by trying a different printer.

If none of that works, you might need to take the divide'n'conquor approach.
Remove things until it works, and then you can pin down where the problem
lies.
 
B

Brian

Thank you, Allen.

It was, indeed, related to the report/subreport link.

I had originally linked Field1 (Master) to Field1 (Child) and had an
invisible text box for Field1 on the subreport. I switched to linking Field1
(Master) to Field2 (Child) and removed Field1 from the report's data source
but did not remove the invisible text box. So, I had a phantom text box that
referred to Field1 that existing in one of the two tables involved in the
report's RecordSource but was not included in the actual SELECT statement.
Now I'm surprised that it worked at all.

But, all's well that ends well, at least as far as programming is
concerning. I removed the Field1 text box from the subreport, and it is now
functioning correctly.

Thanks again for the quick response & the help.
 

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