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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass Values To Report Printing Silently

Status
Not open for further replies.

zipur

Programmer
Jul 5, 2002
13
0
0
CA
I have a button that prints a report based on the data of a form. This works great, BUT...

I want to label the report depending on the contents of the form... for example if the StartDate and EndDate of the report are based on 2 fields on a form, how can I show these values in the header of the report?

This is the simple call I have so far:

'account summary report
If Check43.Value = -1 Then
stDocName = "AccountSummary"
stLinkCriteria = &quot;[LDateOut] >= #&quot; & StartDate & &quot;# AND [LDateOut] <= #&quot; & EndDate & &quot;#&quot;
If Frame8.Value = 1 Then 'send to printer
DoCmd.OpenReport stDocName, acViewNormal, , stLinkCriteria
ElseIf Frame8.Value = 2 Then 'send to screen
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
End If
End If


***This works great for data output, but how do I send StartDate & EndDate to the report if it is printing as acViewNormal ???
 
Hi,

If I understand what you are trying to do you should set the CONTROL SOURCE of the control in the header of your report to [Forms]![FormName].[ControlName] Since the form is still open the data will be instantly copied.

Hope it helps you out. Salvatore Grassagliata
 
k, that works BUT is there a wat to use Defined Variables from the form in the report? If not I could create some hidden form fields and transfer them that way OR create a global or something. Just wanted to know if you can Define a Variable in a form and then pass it to the report?
 
You could create a text box with an invisible property and use that to pass your data. Might not be the cleanest way, but it works.
 
I have to do this one some of my reports and, my way to do it is to have a function with a static variable in it.

Public Function Pass_Var(Optional YourVar)
Static Var

If Not (IsMissing(YourVar)) Then Var = YourVar

Pass_Var = Var

End Function

This way you can set the variable on your button click event and assing the function to the control source property of the control on your report. Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top