Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database Window UnHides When Printing Form

Status
Not open for further replies.

kopy

Technical User
May 30, 2002
141
US
I have a form with a button to print another form. When I execute the following code, the database window unhides.

Dim stDocName As String
Dim MyForm As Form

stDocName = "frmPrintPictureLandscaspe"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False

Why does it do this and how can I keep the database window hidden?

Thanks for any help,
Kopy
 
How are ya kopy . . .

For an object to receive the focus (when selected) in the database window, the database window has to be open not hidden. For your code I believe this happens in the following line:
Code:
[blue]DoCmd.SelectObject acForm, stDocName, [purple][b]True[/b][/purple][/blue]
Here [purple]True[/purple] selects the form object in the database window.

See DoCmd.SelectObject Method which states in the remarks section:
Microsoft said:
[blue]You can use the SelectObject method to select a specified database object.

The SelectObject action works with any Access object that can receive the focus. This action gives the specified object the focus and [purple]shows the object if it's hidden.[/purple][/blue]

To get around it you can try hiding the window again with the following, just after the SelectObject line:
Code:
[blue]   Docmd.SelectObject acForm, , True
   Docmd.RunCommand acCmdWindowHide[/blue]

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top