commands in reports

F

Fubardave

I want to display a form which provides navigation, print, close buttons etc
for moving aroung reports.

Can anyone help as to the best way to achieve this ??

Dave
 
B

BruceM

I'm not sure exactly what you mean when you refer to navigation buttons on a
form for report actions such as print, but it sounds as if a custom toolbar
or menu bar may be of use. See Access Help on the topic:
"Attach a menu or toolbar to a form or report"
 
F

Fubardave

Many thanks Bruce

BruceM said:
I'm not sure exactly what you mean when you refer to navigation buttons on a
form for report actions such as print, but it sounds as if a custom toolbar
or menu bar may be of use. See Access Help on the topic:
"Attach a menu or toolbar to a form or report"
 
F

Fubardave

I am sure I read somewhere that you could have a sub-from displayed over a
report and that sub-form could contain command buttons, for say, printing,
closing the report etc.

How do I make such a form
 
B

BruceM

I have not attempted to use a form for that reason, and cannot advise you
about how to proceed. I have seen ways to create what are often knows as
floating toolbars, but have not used them myself. Custom menus and toolbars
have answered my needs so far.

A quick search in Google groups for:

Access report "floating toolbar"

turned up this code:
______________________________
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

___________________________


A further search may turn up more suggestions.
 
F

Fubardave

Bruce,

once again many thanks for your help

BruceM said:
I have not attempted to use a form for that reason, and cannot advise you
about how to proceed. I have seen ways to create what are often knows as
floating toolbars, but have not used them myself. Custom menus and toolbars
have answered my needs so far.

A quick search in Google groups for:

Access report "floating toolbar"

turned up this code:
______________________________
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

___________________________


A further search may turn up more suggestions.
 
F

Fubardave

Bruce,

is there any way to code in moving to the next or previous page of a report
using the same method ?
 
L

lailanie

can somebody help me
set upp a e-mail??
Fubardave said:
Bruce,

is there any way to code in moving to the next or previous page of a
report
using the same method ?
 
B

BruceM

I do not know of any way to do that other than using the built-in navigation
buttons. I'm not saying for sure there is no way, but only that I do not
know what it is. It would be best to start a new thread in the Reports
group. Provide enough detail that they know what you have tried so far, and
what exactly you hope to do.
 
F

Fubardave

Thanks again Bruce

BruceM said:
I do not know of any way to do that other than using the built-in navigation
buttons. I'm not saying for sure there is no way, but only that I do not
know what it is. It would be best to start a new thread in the Reports
group. Provide enough detail that they know what you have tried so far, and
what exactly you hope to do.
 
Top