Access 97: Print report without type CTRL + P

M

Michael Dekson

Access 97.
I make a report and I want first to see report and then print report without
type CONTROL + P.
Can I make some button or can I see print button in toolbar meny.
Thanks
 
W

Wayne Morgan

There should be a print button on the default report toolbar when you open
the report in preview mode. You can also use the File|Print option.
 
D

DS NTE

Here is how I do it (Thanks to many people in this NG):
The idea is to make a floating toolbar when the report opens:
(You have to translate som text from Norwegian but I think you will
understand)

In a standard module:
'****************************
' Makes a floating menu
Sub AddNewCB()
Dim CBar As CommandBar, CBarCtl As CommandBarControl
On Error GoTo AddNewCB_Err
FjernBar

Set CBar = CommandBars.Add(Name:="Skriv ut eller lukk",
Position:=msoBarFloating)
CBar.Visible = True

Set CBarCtl = CBar.Controls.Add(Type:=msoControlButton)

With CBarCtl
.Caption = " Skriv ut "
.Style = msoButtonCaption
.TooltipText = "Skriv Ut"
.OnAction = "=PrintNow()"
End With

Set CBarCtl3 = CBar.Controls.Add(Type:=msoControlButton)

With CBarCtl3
.Caption = " Velg skriver "
.Style = msoButtonCaption
.BeginGroup = True
.TooltipText = "Velg skriver"
.OnAction = "=ChoosePrint()"
End With


Set CBarCtl2 = CBar.Controls.Add(Type:=msoControlButton)

With CBarCtl2
.Caption = " Lukk "
.Style = msoButtonCaption
.BeginGroup = True
.TooltipText = "Lukk rapporten"
.OnAction = "=LukkRapport()"
End With



Exit Sub

AddNewCB_Err:
MsgBox "Error " & Err.Number & vbCr & Err.Description
Exit Sub

End Sub
'************************
' Removes the floating toolbar
Sub FjernBar()

foundFlag = False
delBars = 0
For Each bar In CommandBars
If (bar.BuiltIn = False) And _
(bar.Visible = True) Then
bar.Delete
foundFlag = True
delBars = delBars + 1
End If
Next bar
For Each bar In CommandBars
If (bar.BuiltIn = False) And _
(bar.Visible = False) Then
bar.Delete
foundFlag = True
delBars = delBars + 1
End If
Next bar

End Sub
'***************************
' Prints the report
Public Function PrintNow()
On Error Resume Next
Dim strRptName
strRptName = Screen.ActiveReport.Name
DoCmd.SelectObject acReport, strRptName, False
DoCmd.PrintOut acPrintAll
End Function

'**************************
'Choose printer
Public Function ChoosePrint()
On Error Resume Next
Dim strRptName
strRptName = Screen.ActiveReport.Name
DoCmd.SelectObject acReport, strRptName, False
DoCmd.RunCommand acCmdPrint
End Function

'***************************
' Close report whitout printing
Public Function LukkRapport()
On Error Resume Next
Dim strRptName
strRptName = Screen.ActiveReport.Name
DoCmd.SelectObject acReport, strRptName, False
DoCmd.RunCommand acCmdClose
End Function


In the module for the report:
'*****************************'
Private Sub Report_Open(Cancel As Integer)
AddNewCB
DoCmd.Maximize
End Sub

Private Sub Report_Close()
FjernBar
DoCmd.Restore
End Sub
'**************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top