Focus

  • Thread starter Thread starter Eric
  • Start date Start date
E

Eric

For some reason the focus of my database is all screwed
up.
If I open a report then click print sometimes it will not
print the report. Sometimes it will print a previous
form that I have open, even though it used to work
properly.
So how do I set the focus to a report, since it has no
SetFocus command?

Thanks
 
I a guessing that you have a custom menu bar for your reports.

If you do, then likely your problem is that you have a form running with a
timer event.

That timer event can accidentally change the focus really fast, and during
the print operation, you get that form with the timer event.

The soltion is simple, and you just need to change your code behind your
print buttion.

The follwing should work:

Thus, the select object command is needed to fix a "focus" bug if you have a
form
with a timer function.

For the code that pops up the printer dialog (so the user can change
printers etc).

You can use:


On Error Resume Next
DoCmd.SelectObject acReport, Screen.ActiveReport.Name
DoCmd.RunCommand acCmdPrint

The code to print right to the printer while in preview mode can be:

On Error Resume Next
Dim strReportName as string
strREportName = Screen.ActiveReport.Name
DoCmd.SelectObject acReport, strReportName
DoCmd.PrintOut acPrintAll
 
Back
Top