Opening Tables and/or Reports in "hidden" mode

  • Thread starter Thread starter waynemb
  • Start date Start date
W

waynemb

Is it possible to open a table or report in something similar to the "hidden"
mode 'acHidden' used with forms?

I'm opening a table, deleting all the records, and closing it. This
operation causes an ugly flashing of the monitor. I'd like to eliminate
that by opening the table in a hidden mode.

DoCmd.OpenTable "MyTable", acViewNormal, acEdit


Also I'm opening a report in order to export it to an rtf file, and then
closing it. This also causes an ugly flash of the monitor. I'd like to be
able to export the file without the visible opening, hopefully by opening it
in hidden mode or something.

DoCmd.OpenReport "MyReport", acViewPreview, "", ""
DoCmd.OutputTo acReport, "MyReport", "RichTextFormat(*.rtf)",
MyFileName, False, ""
DoCmd.Close acReport, "MyReport"

Thanks
 
You can open a report in hidden mode only in Access 2002 or later.

You don't need to open Table1 to delete all its records. Just use:
dbEngine(0)(0).Execute "DELETE FROM Table1;", dbFailOnError
 
DoCmd.OpenReport "MyReport", acViewPreview, "", ""
DoCmd.OutputTo acReport, "MyReport", "RichTextFormat(*.rtf)",
MyFileName, False, ""
DoCmd.Close acReport, "MyReport"

You don't need to open the report at all, just use the OutputTo command:

DoCmd.OutputTo acReport, "MyReport", "RichTextFormat(*.rtf)", MyFileName,
False, ""
 
Thanks. I don't understand how this works. I looked up
dbEngine(0)(0).Execute, as well as the separate parts of it in Help, but
didn't find anything. My two main questions are about the two parameters?
(0), and what dbFailOnError does.

Thanks again
 
DBEngine(0)(0) is shorthand for DBEngine.Workspaces(0).Databases(0). In
other words, it's a reference to the first Database in the first Workspace
associated with the DBEngine object, which should be the same database as
CurrentDb().

dbFailOnError, used in conjunction with the Execute method of the Database,
QueryDef or Connection object (assuming dealing strictly with a Jet
database), rolls back updates if an error occurs, plus raises a trappable
error that can be intercepted using proper error handling techniques.
 
Back
Top