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.
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.