Hidden Database window problem

PearlGI

Registered User.
Local time
Today, 19:44
Joined
Aug 30, 2001
Messages
125
I'm using the following lines to output a series of reports to rtf format files.

While Not rs1.EOF
DoCmd.OutputTo acOutputReport, rs1!rname, acFormatRTF, strPath & rs1!rname & ".doc"
rs1.MoveNext
Wend

This works fine. :)

However, when I distribute the db with the database window hidden, it falls over when attempting to output the 2nd report and gives this error message:

2046: The command or action 'OutputTo' isn't available now

The problem appears to lie with the fact that the database is hidden.

I've tried using [DoCmd.RunCommand acCmdWindowUnhide] before the loop and [DoCmd.RunCommand acCmdWindowHide] after the loop to temporarily unhide the window. But this requires a [SendKeys Chr(13)] before the unhide command as a dialogbox pops-up asking which window to unhide (although there is only 1 :( ).

This solution only works if the db has focus because of the SendKeys action.


Can anybody think of any other solution?
 
Have you tried using DoEvents after the OutputTo?
 
I've tried it before and after, but neither worked.

It's one of those problems - do you fix the problem or invent a work-a-round solution.

I believe the problem is an ACC97 quirk - so I'm trying to find a work-a-round.
 
Any ideas as to how you would you select the database window object?
 
That's it. Many thanks.

I'd have never worked that out - didn't realise the database window was classed as a form!

Just to recap (in case anybody has a similar need):

DoCmd.SelectObject, acForm, , True (unhides the database window)

and

DoCmd.RunCommand acCmdWindowHide (hides the database window)

:rolleyes:
 
PearlGI said:
That's it. Many thanks.

I'd have never worked that out - didn't realise the database window was classed as a form!


:rolleyes:
I don't think it is, this cheat works by leaving the form name argument blank
 
DoCmd.RunCommand acCmdWindowHide
Doesn't this only work if the database window is the current selected window?
 
No, I've tried it with the db minimised and it works fine.
 
You guys are so great!!

I was almost ready to pull my hair because I had my macro to output to all working and then decided to go under startup and hide the database window...Well, it would work sometimes and sometimes it wouldnt...

So, then I showed the database window again and it started working right...

And here is the answer to hide the window!!!!! You make me look SO GOOD to my boss..

Thanks, Noreene
 

Users who are viewing this thread

Back
Top Bottom