VBA Code opens the navigation bar in AC 2007

fishmort

New Member
Joined
Jan 28, 2008
Messages
1
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
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hi, and welcome to the Board!

Have you tried debugging the code to see where it displays the navigation bar? Put a break point near the top of the code, run it, then step through using F8.

By the way, your code will be much easier to read if you wrap it in CODE tags. Place [ CODE ] to start, and [ /CODE ] to end... but leave out the spaces in the square brackets.

Denis
 
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,411
Members
449,081
Latest member
JAMES KECULAH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top