Help on Report

  • Thread starter ghostman via AccessMonster.com
  • Start date
G

ghostman via AccessMonster.com

Im having trouble in showing reports on a list box.

I have a form with a list of reports listed inside a list box. what i want is
to select a report from the list box and print preview it by clicking on a
button.

I think it can be done using macros, but how? pleas help, im just a newbie...

also, if i select a report from the same list box (same form), for example a
report that will show training record during a specified date, lets say month
of June 2009, and if i select that report, it should ask me to enter the date
and should preview the data i requested..how can this be done?
 
G

ghostman via AccessMonster.com

thank you for the help, but im having some problems.

i followed the 2nd procedure exactly, (i guess)

- a list box named lstReports, with a label Reports;
- a check box named chkPreview, with a label Preview;
- a command button named cmdOpenReport, with caption Open Report.

I set the command button's OnClick property to [Event Procedure] with this
code:

Private Sub cmdOpenReport_Click()
' Purpose: Opens the report selected in the list box.
On Error GoTo cmdOpenReport_ClickErr
If Not IsNull(Me.lstReports) Then
DoCmd.OpenReport Me.lstReports, IIf(Me.chkPreview.Value,
acViewPreview, acViewNormal)
End If
Exit Sub

cmdOpenReport_ClickErr:
Select Case Err.Number
Case 2501 ' Cancelled by user, or by NoData event.
MsgBox "Report cancelled, or no matching data.", vbInformation,
"Information"
Case Else
MsgBox "Error " & Err & ": " & Error$, vbInformation,
"cmdOpenReport_Click()"
End Select
Resume Next
End Sub



- set the list box's RowSourceType property to EnumReports.

and createa a new module and added the function you provided into this module:



...but it shows me a compile error: Method or data member not found..
and showed me the code where Me.lstReports is highlighted...


what could be the problem? can you guide me through this one?



Allen said:
See:
List Box of Available Reports
at:
http://allenbrowne.com/ser-19.html

The article gives 2 solutions. The first is the simpler.

Once you have the list box, use OpenReport in a macro or VBA code to fire
off the report.
Im having trouble in showing reports on a list box.
[quoted text clipped - 14 lines]
date
and should preview the data i requested..how can this be done?
 
A

Allen Browne

Things to check:

1. Do you have a list box named lstReports on this form?

2. Do you have a check box named chkPreview on this form?

3. Did you put the EnumReports function in a standard module?

4. Does your code compile okay (Compile on the Debug menu, in the code
window)?

5. Does the list box show the report names?

6. What version of Access are you using?

7. Immediately above the OpenReport line, aee:
Debug.Print Me.lstReports
When it runs, see if the correct name comes out in the Immediate Window
(Ctrl+G.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.
ghostman via AccessMonster.com said:
thank you for the help, but im having some problems.

i followed the 2nd procedure exactly, (i guess)

- a list box named lstReports, with a label Reports;
- a check box named chkPreview, with a label Preview;
- a command button named cmdOpenReport, with caption Open Report.

I set the command button's OnClick property to [Event Procedure] with this
code:

Private Sub cmdOpenReport_Click()
' Purpose: Opens the report selected in the list box.
On Error GoTo cmdOpenReport_ClickErr
If Not IsNull(Me.lstReports) Then
DoCmd.OpenReport Me.lstReports, IIf(Me.chkPreview.Value,
acViewPreview, acViewNormal)
End If
Exit Sub

cmdOpenReport_ClickErr:
Select Case Err.Number
Case 2501 ' Cancelled by user, or by NoData event.
MsgBox "Report cancelled, or no matching data.", vbInformation,
"Information"
Case Else
MsgBox "Error " & Err & ": " & Error$, vbInformation,
"cmdOpenReport_Click()"
End Select
Resume Next
End Sub



- set the list box's RowSourceType property to EnumReports.

and createa a new module and added the function you provided into this
module:



..but it shows me a compile error: Method or data member not found..
and showed me the code where Me.lstReports is highlighted...


what could be the problem? can you guide me through this one?



Allen said:
See:
List Box of Available Reports
at:
http://allenbrowne.com/ser-19.html

The article gives 2 solutions. The first is the simpler.

Once you have the list box, use OpenReport in a macro or VBA code to fire
off the report.
Im having trouble in showing reports on a list box.
[quoted text clipped - 14 lines]
date
and should preview the data i requested..how can this be done?
 
G

ghostman via AccessMonster.com

its working now, i use macro to print the selected record on the list box.

i created a query with the list of report that i want to print and linked
that to my list box...(Row Source)
because i want also to edit the list if i want to.. (Added EDIT REPORT LIST
BUTTON)

then i did some macro on the following:

OPEN REPORT BUTTON:
Macro Name: cmdOpenReport : On Click
Action: OpenReport
Arguments: =[Forms]![View Reports]![lstReports], Print Preview, , , Dialog

LISTBOX:
Macro Name: lstReports : On Dbl Click
Action: OpenReport
Arguments: =[Forms]![View Reports]![lstReports], Print Preview, , , Dialog

then, it worked the way i want.. :)
Thank you very much...



Allen said:
Things to check:

1. Do you have a list box named lstReports on this form?

2. Do you have a check box named chkPreview on this form?

3. Did you put the EnumReports function in a standard module?

4. Does your code compile okay (Compile on the Debug menu, in the code
window)?

5. Does the list box show the report names?

6. What version of Access are you using?

7. Immediately above the OpenReport line, aee:
Debug.Print Me.lstReports
When it runs, see if the correct name comes out in the Immediate Window
(Ctrl+G.)
thank you for the help, but im having some problems.
[quoted text clipped - 53 lines]
 

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