A
Aliza Klein
Hi.
My user would like to create his own Crystal Reports (no clue as to why...)
and then be able to run them from the Access 2000 system I am developing
from a custom menu that lists all the .rpt (Crystal Reports file type) in
the directory.
I have done a dynamic custom menus before that lists all the Access Reports
in the database.
This may seem stupid - but: how do I loop through and locate the .RPT
files?
I think if I can loop through the name of the files, I can probably figure
out how to build the menu similar to the way I did it for the Access reports
(code below).
_______
Set cboReport = cbr.Controls.add( _
Type:=msoControlPopup)
With cboReport
.Tag = "Crystal Reports"
.Caption = "&Reports"
.TooltipText = "Reports"
End With
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject
'get the number or reports
icount = dbs.AllReports.Count
'make an array that size
Dim cboRepList()
ReDim Preserve cboRepList(icount)
' Search for open AccessObject objects in AllReports collection.
i = 0
'disable the menu bar
cboReport.Enabled = False
For Each obj In dbs.AllReports
Set cboRepList(i) = cboReport.Controls.add()
With cboRepList(i)
.Tag = i
.Caption = obj.Name
.Enabled = False
'are going to call a basic function and grab name later
.OnAction = "ShowReport"
.TooltipText = obj.Name
.Enabled = True
End With
i = i + 1
Next obj
' enable the menu
cboReport.Enabled = True
__________
Sub ShowReport()
Dim strCaption As String
Dim cbc As CommandBarControl
Dim cbcItem As CommandBarControl
'get the selected control and store its caption
Set cbc = CommandBars.ActionControl
strCaption = cbc.Caption
'the caption is the same as the report name
'run it!
DoCmd.OpenReport strCaption, acViewPreview
End Sub
_____________________________
Any better ideas then simply adapting the above as well as how to actually
get the file names, would be greatly appreciated!
Thanks!
aliza
My user would like to create his own Crystal Reports (no clue as to why...)
and then be able to run them from the Access 2000 system I am developing
from a custom menu that lists all the .rpt (Crystal Reports file type) in
the directory.
I have done a dynamic custom menus before that lists all the Access Reports
in the database.
This may seem stupid - but: how do I loop through and locate the .RPT
files?
I think if I can loop through the name of the files, I can probably figure
out how to build the menu similar to the way I did it for the Access reports
(code below).
_______
Set cboReport = cbr.Controls.add( _
Type:=msoControlPopup)
With cboReport
.Tag = "Crystal Reports"
.Caption = "&Reports"
.TooltipText = "Reports"
End With
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject
'get the number or reports
icount = dbs.AllReports.Count
'make an array that size
Dim cboRepList()
ReDim Preserve cboRepList(icount)
' Search for open AccessObject objects in AllReports collection.
i = 0
'disable the menu bar
cboReport.Enabled = False
For Each obj In dbs.AllReports
Set cboRepList(i) = cboReport.Controls.add()
With cboRepList(i)
.Tag = i
.Caption = obj.Name
.Enabled = False
'are going to call a basic function and grab name later
.OnAction = "ShowReport"
.TooltipText = obj.Name
.Enabled = True
End With
i = i + 1
Next obj
' enable the menu
cboReport.Enabled = True
__________
Sub ShowReport()
Dim strCaption As String
Dim cbc As CommandBarControl
Dim cbcItem As CommandBarControl
'get the selected control and store its caption
Set cbc = CommandBars.ActionControl
strCaption = cbc.Caption
'the caption is the same as the report name
'run it!
DoCmd.OpenReport strCaption, acViewPreview
End Sub
_____________________________
Any better ideas then simply adapting the above as well as how to actually
get the file names, would be greatly appreciated!
Thanks!
aliza