acViewPreview

D

Dwight

I have an application that has a command button that opens a query in preview
mode.

DoCmd.OpenQuery "myquery", acViewPreview

This works just fine, but when I click the close button on the preview
window, only the preview window closes. Is there a way to make the query
close at the same time?

Thanks in advance!

Dwight
 
F

fredg

I have an application that has a command button that opens a query in preview
mode.

DoCmd.OpenQuery "myquery", acViewPreview

This works just fine, but when I click the close button on the preview
window, only the preview window closes. Is there a way to make the query
close at the same time?

Thanks in advance!

Dwight

When you open a query in acViewPreview, you are actually getting a
report view of the query, not the query datasheet itself.
Therefore you need to close the report and then close the query behind
it.
Queries are not really designed to be printed or previewed. If you
want to print out the query, create a report using the query as it's
record source. Print or preview that report. The query will not even
be opened.

DoCmd.OpenQuery "myquery"
will open and display just the query in datasheet view if that's what
you want.
 
Top