Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide/Show Detail to create a Detail and Summary

Status
Not open for further replies.

tsefly

Programmer
Nov 5, 2001
5
US
How can I pass a parameter to print one report two different ways?

I want a longer report that shows all details, and a shorter report that just shows the group footers, but I don't want to create, maintain and verify two separate reports.

This will be a VBA function is possible. Help ASAP is appreciated.

Thanks,
Eliz.
 
The first thing to do is add a tickbox to the form you are calling the report from.
If you are previewing the report before printing then you can add something like this to the preview button:

If Me![HideDetail] = -1 Then
DoCmd.OpenReport "z7", acPreview, , ("[OwnerID] = " & Me![OwnerID])
Reports![z7].Detail.Visible = False
Else
DoCmd.OpenReport "z7", acPreview, , ("[OwnerID] = " & Me![OwnerID])
End If

if you print directly rather than preview this will not work so try adding code to the open event of the report instead:

If Forms![Menu]![HideDetail] = -1 Then
Me.Detail.Visible = False
End If

The Second option is the most flexible if you are calling the report from just one form.

Hope this helps

Peter
 
Thanks, Peter!

Actually, these reports are called from a macro that is in turn called by a DLL.

Do I set up a function, and call that? How will the function look? I was thinking I could pass a parameter, then say "this param = this, me.visible = true", then make the same docmd within the macro, and send the parameter value that I can analyze false. Does that sound like it would work? How do I write the code?

Thanks again for your help,
Eliz.
 
I don't know of any way of having global variables in access. The nearest it comes is holding data in a form then referring to it from whichever module needs it.
If your DLL can call a function and pass a parameter then there are two options to try, really just expanding on my first post.
1st:

Public Function OpenReports(ShowDetail As Boolean)
If ShowDetail = True Then
DoCmd.OpenReport "z7", acPreview
Reports![z7].Detail.Visible = False
Else
DoCmd.OpenReport "z7", acPreview
End If
End Function

The 2nd will require a form to be created, not necessarily with a table behind it, with a tickbox on it.

Public Function OpenReports(ShowDetail As Boolean)
Docmd.OpenForm "Menu",,,,,acHidden
If ShowDetail = True Then
Forms![Menu]![ShowDetail] = True
Else
Forms![Menu]![ShowDetail] = False
End If
DoCmd.OpenReport "z7", acPrint
DoCmd.Close acForm, "Menu", acSaveNo
End Function

And on the report open event:

If Forms![Menu]![ShowDetail] = True Then
Me.Detail.Visible = True
Else
Me.Detail.Visible = False
End If

There is probably a better way to do it but I have never had to call functions from a DLL before. Once again hth
Peter
 
As a follow up, and after reading thread705-687222 (thanks CajunCenturion et al) try a module with:


Global globalShowDetail as Boolean

Public Function OpenReports(ShowDetail As Boolean)
If ShowDetail = True Then
globalShowDetail = True
Else
globalShowDetail = False
End If
DoCmd.OpenReport "Report Name", acPrint
End Function

And on the report have:

Private Sub Report_Open(Cancel As Integer)
If globalShowDetail = True Then
Me.Detail.Visible = True
Else
Me.Detail.Visible = False
End If
globalShowDetail = False
End Sub

Always Learning
Peter
 
Thanks so much for the help. I love this solution! I don't want to have to edit the dll.

Regards,
Eliz.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top