Hidden Database window problem (1 Viewer)

PearlGI

Registered User.
Local time
Today, 13:50
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?
 

Travis

Registered User.
Local time
Today, 05:50
Joined
Dec 17, 1999
Messages
1,332
Have you tried using DoEvents after the OutputTo?
 

PearlGI

Registered User.
Local time
Today, 13:50
Joined
Aug 30, 2001
Messages
125
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.
 

PearlGI

Registered User.
Local time
Today, 13:50
Joined
Aug 30, 2001
Messages
125
Any ideas as to how you would you select the database window object?
 
R

Rich

Guest
I think it's something like
DoCmd.SelectObject acForm, , True
 

PearlGI

Registered User.
Local time
Today, 13:50
Joined
Aug 30, 2001
Messages
125
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:
 
R

Rich

Guest
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
 

dcx693

Registered User.
Local time
Today, 08:50
Joined
Apr 30, 2003
Messages
3,265
DoCmd.RunCommand acCmdWindowHide
Doesn't this only work if the database window is the current selected window?
 

PearlGI

Registered User.
Local time
Today, 13:50
Joined
Aug 30, 2001
Messages
125
No, I've tried it with the db minimised and it works fine.
 

Noreene Patrick

Registered User.
Local time
Today, 07:50
Joined
Jul 18, 2002
Messages
223
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

Top Bottom