I have the following code on the event of a command button. When I run it it opens the Navigation bar in Access 2007, I don't want that to happen. What am I doing wrong or why is this happening ?
Private Sub btnPrintLabels_Click()
On Error GoTo Err_btnPrintLabels_Click
'confirm to print labels and tell user how many sheets are needed
Dim stDocName As String
Dim lngRetval As Long
lngRetval = MsgBox("Put " & Me.totalsheets.Value & " label sheets into " & _
"the printer, then press OK", vbOKCancel + vbExclamation + vbDefaultButton1, _
"Attention ")
If lngRetval = vbCancel Then
Exit Sub
Else
End If
'print label report sheet
DoCmd.SelectObject acReport, "labelsreport", True
DoCmd.PrintOut acPrintAll
'confirm that the labels printed ok
Dim MsgPrintOK As Long
MsgPrintOK = MsgBox("Did all the Labels print OK ?", vbYesNo + vbQuestion + _
vbDefaultButton1, "Attention ")
If MsgPrintOK = vbNo Then
Exit Sub
Else
'open and preview start build report to be faxed to newton
'close the AllOrdersChecked off form because we dont need it open anymore
'run update query to update all ToBePrinted orders to WasPrinted and go to home screen
MsgBox "Now you have to Fax a Start Build Report to Newton!", vbOKOnly
DoCmd.OpenReport "rptStartBuild", acViewPreview
DoCmd.Close acForm, "frmAllOrdersCheckedOff", acSaveYes
DoCmd.OpenQuery "CheckOffPrintedLabelsUpdateQ"
Exit_btnPrintLabels_Click:
Exit Sub
Err_btnPrintLabels_Click:
MsgBox Err.Description
Resume Exit_btnPrintLabels_Click
End IF
Private Sub btnPrintLabels_Click()
On Error GoTo Err_btnPrintLabels_Click
'confirm to print labels and tell user how many sheets are needed
Dim stDocName As String
Dim lngRetval As Long
lngRetval = MsgBox("Put " & Me.totalsheets.Value & " label sheets into " & _
"the printer, then press OK", vbOKCancel + vbExclamation + vbDefaultButton1, _
"Attention ")
If lngRetval = vbCancel Then
Exit Sub
Else
End If
'print label report sheet
DoCmd.SelectObject acReport, "labelsreport", True
DoCmd.PrintOut acPrintAll
'confirm that the labels printed ok
Dim MsgPrintOK As Long
MsgPrintOK = MsgBox("Did all the Labels print OK ?", vbYesNo + vbQuestion + _
vbDefaultButton1, "Attention ")
If MsgPrintOK = vbNo Then
Exit Sub
Else
'open and preview start build report to be faxed to newton
'close the AllOrdersChecked off form because we dont need it open anymore
'run update query to update all ToBePrinted orders to WasPrinted and go to home screen
MsgBox "Now you have to Fax a Start Build Report to Newton!", vbOKOnly
DoCmd.OpenReport "rptStartBuild", acViewPreview
DoCmd.Close acForm, "frmAllOrdersCheckedOff", acSaveYes
DoCmd.OpenQuery "CheckOffPrintedLabelsUpdateQ"
Exit_btnPrintLabels_Click:
Exit Sub
Err_btnPrintLabels_Click:
MsgBox Err.Description
Resume Exit_btnPrintLabels_Click
End IF