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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database window is popping up with docmd.printout

Status
Not open for further replies.

rsippos

IS-IT--Management
Aug 12, 2003
3
US
I built a database (mde) that this keeps happening to.

I have the following code for a print button on a form. Just to print the contents of the form:

Private Sub PrintForm_Click()
On Error GoTo Err_PrintForm_Click

Dim stDocName As String
Dim MyForm As Form

'Make sure that the user really wanted to print
Dim Msg, Style, Title, Help, Ctxt, Response

Msg = "Are you sure that you want to print this form?" ' Define
message.
Style = vbYesNo + vbDefaultButton2 ' Define buttons.
Title = "Are You Sure?" ' Define title.
Help = "DEMO.HLP" ' Define Help file.
Ctxt = 1000 ' Define topic
' context.
' Display message.

Response = MsgBox(Msg, Style, Title, Help, Ctxt)

If Response = vbYes Then ' User chose Yes.

stDocName = "ExistingQuestionnaire"
Set MyForm = Screen.ActiveForm

DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False

End If

Exit_PrintForm_Click:
Exit Sub
Err_PrintForm_Click:
MsgBox Err.Description
Resume Exit_PrintForm_Click
End Sub


For whatever reason, when you click on the print button that I put on the form, the database window automatically comes up and stays on the screen. It is set in the startup to not be visible to the user. Any help would be great.


 
The culprit is here:
DoCmd.SelectObject acForm, stDocName, [highlight]True[/highlight]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I had a similar problem with the database window showing when it should have been hidden. It turned out to be a problem with Access XP vs. Access 2000. I had to put the hide command in my auto exec to keep it hidden on those running a later version of Access from 2000. For some reason it was not picking up the Startup commands.

Don't know if this will help but I thought I would throw it out.

Hope this helps.

OnTheFly
 
Thanks PHV.... removing the True helped out!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top