creating a common page to access all data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have created some reports which I want to access using a single page. I am
thinking of creating buttons on that page, where each button invokes a report
and displays it. How can I do it?

Thanks for your time
 
Hi Dhaval

It depends on what you want to do.
A simple method would be to create a number of macros and then link this to
an ONClick event of a number of buttons – but your form may start to look
quite full quite quickly.

Or
You could create a single macro with a few report (to print) and then link
this to an AfterUpdate of a list or combo (bound colum) with the Report Names
in the bound column.

Or
If you have specific reports that you want to filter so that users can send
out (as an example) a sales confirmation, or a letter regarding a telephone
call, etc, etc (assuming that each client has a [BookingRef]

You could create a combo box (Print-Select) with the names of the reports
and OnClick you could use

Private Sub PrintSelect_Click()
If (Forms!NameOfMainForm!NameOfSubForm!PrintSelect = "Report1") Then
DoCmd.OpenReport "Report1", acViewNormal, "",
[BookingRef]=[Forms]![NameOfMainForm]![NameOfSubForm].[Form]![BookingRef]",
acNormal
End If
If (Forms!NameOfMainForm!NameOfSubForm!PrintSelect = "Report2") Then
DoCmd.OpenReport "Report2", acViewNormal, "",
[BookingRef]=[Forms]![NameOfMainForm]![NameOfSubForm].[Form]![BookingRef]",
acNormal
End If
If (Forms!NameOfMainForm!NameOfSubForm!PrintSelect = "Report3") Then
DoCmd.OpenReport "Report3", acViewNormal, "",
[BookingRef]=[Forms]![NameOfMainForm]![NameOfSubForm].[Form]![BookingRef]",
acNormal
End If

Etc, Etc.

I would suggest starting with a simple macro to run/print your reports and
then use the OnClick action of your new button on your form. After you have
this up and running you could start to look at some VBA (make a copy of your
D Base) and this to practice on.
 
This is not a great plan. First, as time goes by, you will be adding new
reports. That means that each time you add a report or if you want to delete
a report, you have to go back and change your form. I would suggest either a
Combo Box or a Multi Select List Box (If you want the user to be able to
select more than one report at a time). You can populate either using the
Application object. Then the user can select from the list of reports.

Dim rpts As Reports
Dim rpt As Report
Dim strRptList As String

Set rpts = Application.CurrentProject.AllReports
For Each rpt in rpts
strRptList = strRptList & rpt.Name & ";"
Next rpt

strRptList = Left(strRptLost, Len(strRptList) -1)

Me.lstReportList.RowSource = strRptList

If you use a combo, open the report in the After Update event of the combo:

If IsNull(Me.cboReportList) Then
MsgBox "No Report Selected to Print"
Else
DoCmd.OpenReport Me.cboReportList
End If

If you chose to use a multi select List Box, Add a command button Run Reports

Dim varItm As Variant
Dim strRptName As String
Dim ctl As Control

Set ctl = Me.lstReportList
If ctl.ItemsSelected.Count = 0 Then
MsgBox "No Reports Selected To Print"
Else
For Each varItm In ctl.ItemsSelected
strRptName = ctl.ItemData(varItm)
DoCmd.OpenReport strRptName
Next varItm
End If

set ctl = Nothing
 
I know I'm a novice, but I thought a "switchboard" was either specifically
designed for what you want, or at the very least, commonly used for it.
 
I have started developing a db for my husband's department at work. As you
might imagine, I have a gazillion questions. Thanks to you, I now have one
less than a gazillion. I could not get the switchboard that I did manage to
create to open on startup. It does now. Thank you very much!
 
Back
Top