
June 27th, 2008, 08:22 PM
|
|
|
Print a report 3 times with 3 different fields visible
Hi,
I have report which I need to print 3 times, but would like to have
the following headings
Customer Copy - Print 1
Accounts Copy - Print 2
File Copy -Print 3
I created a macro to print the report three times, but do not know how
I can display each text field for each print.
Can anybody point me in the right direction.
|

June 27th, 2008, 08:22 PM
|
|
|
Re: Print a report 3 times with 3 different fields visible
Studiotyphoon wrote:
Quote:
Hi,
>
I have report which I need to print 3 times, but would like to have
the following headings
>
Customer Copy - Print 1
Accounts Copy - Print 2
File Copy -Print 3
>
I created a macro to print the report three times, but do not know how
I can display each text field for each print.
>
Can anybody point me in the right direction.
|
What version of Access are you using? There is an OpenArgs parameter
you can pass to the report in A2003. Ex:
DoCmd.OpenReport "YourReportName", , , , , "1"
DoCmd.OpenReport "YourReportName", , , , , "2"
DoCmd.OpenReport "YourReportName", , , , , "3"
The 1,2,3 is the argument. I created a report called Report1. I
created 2 text boxes; Text1 and Text2. I put Text1 in the report's
header, visible = False. I put Text2 in the Report footer.
In Text1 I entered, for the ControlSource in the Data tab,
=NZ([Reports]![Report1].[OpenArgs],"0")
as Report1 is the name of the report.
In Text2 I entered
=IIf([Text1]="1","Customer",IIf([Text1]="2","Account","File")) & " Copy"
in the control source.
Now when I run the report, depending on the argument passed, it prints
the value I want.
Fireballs
http://www.youtube.com/watch?v=uzkNI4YIU2o
|

June 27th, 2008, 08:22 PM
|
|
|
Re: Print a report 3 times with 3 different fields visible
On Apr 19, 8:51*pm, Salad <o...@vinegar.comwrote:
Quote:
Studiotyphoon wrote:>
Quote:
I have report which I need to print 3 times, but would like to have
the following headings
|
>
Quote:
Customer Copy - Print 1
Accounts Copy - Print 2
File Copy -Print 3
|
>
Quote:
I created a macro to print the report three times, but do not know how
I can display each text field for each print.
|
>
Quote:
|
Can anybody point me in the right direction.
|
>
What version of Access are you using? *There is an OpenArgs parameter
you can pass to the report in A2003. *Ex:
* * * * DoCmd.OpenReport "YourReportName", , , , , "1"
* * * * DoCmd.OpenReport "YourReportName", , , , , "2"
* * * * DoCmd.OpenReport "YourReportName", , , , , "3"
>
The 1,2,3 is the argument. *I created a report called Report1. *I
created 2 text boxes; Text1 and Text2. *I put Text1 in the report's
header, visible = False. *I put Text2 in the Report footer.
>
In Text1 I entered, for the ControlSource in the Data tab,
* * * * =NZ([Reports]![Report1].[OpenArgs],"0")
as Report1 is the name of the report.
>
In Text2 I entered
* * * * =IIf([Text1]="1","Customer",IIf([Text1]="2","Account","File")) & " Copy" * * * *
in the control source.
>
Now when I run the report, depending on the argument passed, it prints
the value I want.
>
Fireballshttp://www.youtube.com/watch?v=uzkNI4YIU2o
|
Thanks for help so far.
Running Access 2003, SP2
But still struggling to get it to work.
I've added the following into the report under On Open Event
Quote:
DoCmd.OpenReport "YourReportName", , , , , "1"
DoCmd.OpenReport "YourReportName", , , , , "2"
DoCmd.OpenReport "YourReportName", , , , , "3"
|
When I try running the report it comes up with an error against the
first line of the code.
Should this code be in the report or Form for the OpenArgs to be used.
Also see my reply direct to your email.
Thanks in advance -
|

June 27th, 2008, 08:22 PM
|
|
|
Re: Print a report 3 times with 3 different fields visible
Studiotyphoon wrote:
Quote:
On Apr 19, 8:51 pm, Salad <o...@vinegar.comwrote:
>
Quote:
>>Studiotyphoon wrote:
>>>>
Quote:
>>>I have report which I need to print 3 times, but would like to have
>>>the following headings
|
>>
Quote:
>>>Customer Copy - Print 1
>>>Accounts Copy - Print 2
>>>File Copy -Print 3
|
>>
Quote:
>>>I created a macro to print the report three times, but do not know how
>>>I can display each text field for each print.
|
>>
Quote:
|
>>>Can anybody point me in the right direction.
|
>>
>>What version of Access are you using? There is an OpenArgs parameter
>>you can pass to the report in A2003. Ex:
> DoCmd.OpenReport "YourReportName", , , , , "1"
> DoCmd.OpenReport "YourReportName", , , , , "2"
> DoCmd.OpenReport "YourReportName", , , , , "3"
>>
>>The 1,2,3 is the argument. I created a report called Report1. I
>>created 2 text boxes; Text1 and Text2. I put Text1 in the report's
>>header, visible = False. I put Text2 in the Report footer.
>>
>>In Text1 I entered, for the ControlSource in the Data tab,
> =NZ([Reports]![Report1].[OpenArgs],"0")
>>as Report1 is the name of the report.
>>
>>In Text2 I entered
> =IIf([Text1]="1","Customer",IIf([Text1]="2","Account","File")) & " Copy"
>>in the control source.
>>
>>Now when I run the report, depending on the argument passed, it prints
>>the value I want.
>>
>>Fireballshttp://www.youtube.com/watch?v=uzkNI4YIU2o
|
>
>
Thanks for help so far.
>
Running Access 2003, SP2
>
But still struggling to get it to work.
>
I've added the following into the report under On Open Event
>
>
Quote:
> DoCmd.OpenReport "YourReportName", , , , , "1"
> DoCmd.OpenReport "YourReportName", , , , , "2"
> DoCmd.OpenReport "YourReportName", , , , , "3"
|
>
>
When I try running the report it comes up with an error against the
first line of the code.
|
I don't use macros. I checked the Macro builder and there's no OpenArgs
capability with them. I suppose you could use RunCode and in a code
module put the OpenReport lines in the sub.
Did you change "YourReportName" to the name of your report?
Quote:
|
Should this code be in the report or Form for the OpenArgs to be used.
|
Usually I call reports from a form. I might have a command button
CommandReport with a caption of "Report". In the OnClick event I would
have those 3 lines. I would not have them in the Report's module.
Quote:
>
Also see my reply direct to your email.
|
I don't think it made it. Sald may mix with oil and vinegar but there's
not such email address as far as I know.
Remember, I created a text box in the Report header band. I have
=NZ([Reports]![Report1].[OpenArgs],"0")
as the Control source (under data tab of property sheet). You need to
change Report1 to your report's name.
In the footer band I put another textbox at the bottom to print the message.
=IIf([Text1]="1","Customer",IIf([Text1]="2","Account","File"))
You need to change Text1 to the name of the Textbox in the Report header.
Here's another thing you could do. Forget the first textbox...put the
second text box at the footer. Now open the code module for the report
and put this code into it.
Private Function GetCopyText() As String
'if no argument passed default to "File". Press F1
'on the word NZ for help if necessary.
Select Case NZ(Me.OpenArgs,3)
Case 1
GetCopyText = "Customer"
Case 2
GetCopyText = "Accounts"
Case Else
GetCopyText = "File"
End Select
GetCopyText = GetCopyText & " Copy - Print "
GetCopyText = GetCopyText & NZ(Me.OpenArgs,3)
End Function
Now in the ControlSource for the textbox in the report's page footer enter
=GetCopyText()
This will call the function GetCopyText and print the result in the footer.
Either way works.
Feels Good
http://www.youtube.com/watch?v=xA4lPE4MI6A&NR=1
|

June 27th, 2008, 08:22 PM
|
|
|
Re: Print a report 3 times with 3 different fields visible
On Apr 21, 4:29*pm, Salad <o...@vinegar.comwrote:
Quote:
Studiotyphoon wrote:
Quote:
|
On Apr 19, 8:51 pm, Salad <o...@vinegar.comwrote:
|
>>>
Quote:
Quote:
>>I have report which I need to print 3 times, but would like to have
>>the following headings
|
|
>
Quote:
Quote:
>>Customer Copy - Print 1
>>Accounts Copy - Print 2
>>File Copy -Print 3
|
|
>
Quote:
Quote:
>>I created a macro to print the report three times, but do not know how
>>I can display each text field for each print.
|
|
>
Quote:
Quote:
|
>>Can anybody point me in the right direction.
|
|
>
Quote:
Quote:
>What version of Access are you using? *There is an OpenArgs parameter
>you can pass to the report in A2003. *Ex:
* * * *DoCmd.OpenReport "YourReportName", , , , , "1"
* * * *DoCmd.OpenReport "YourReportName", , , , , "2"
* * * *DoCmd.OpenReport "YourReportName", , , , , "3"
|
|
>
Quote:
Quote:
>The 1,2,3 is the argument. *I created a report called Report1. *I
>created 2 text boxes; Text1 and Text2. *I put Text1 in the report's
>header, visible = False. *I put Text2 in the Report footer.
|
|
>
Quote:
Quote:
>In Text1 I entered, for the ControlSource in the Data tab,
* * * *=NZ([Reports]![Report1].[OpenArgs],"0")
>as Report1 is the name of the report.
|
|
>
Quote:
Quote:
>In Text2 I entered
* * * *=IIf([Text1]="1","Customer",IIf([Text1]="2","Account","File")) & " Copy" * * * *
>in the control source.
|
|
>
Quote:
Quote:
>Now when I run the report, depending on the argument passed, it prints
>the value I want.
|
|
>
Quote:
Quote:
|
>Fireballshttp://www.youtube.com/watch?v=uzkNI4YIU2o
|
|
>>>
Quote:
|
But still struggling to get it to work.
|
>
Quote:
|
I've added the following into the report under On Open Event
|
>
Quote:
Quote:
* * * *DoCmd.OpenReport "YourReportName", , , , , "1"
* * * *DoCmd.OpenReport "YourReportName", , , , , "2"
* * * *DoCmd.OpenReport "YourReportName", , , , , "3"
|
|
>
Quote:
When I try running the report it comes up with an error against the
first line of the code.
|
>
I don't use macros. *I checked the Macro builder and there's no OpenArgs
capability with them. *I suppose you could use RunCode and in a code
module put the OpenReport lines in the sub.
>
Did you change "YourReportName" to the name of your report?
>
Quote:
|
Should this code be in the report or Form for the OpenArgs to be used.
|
>
Usually I call reports from a form. *I might have a command button
CommandReport with a caption of "Report". *In the OnClick event I would
have those 3 lines. *I would not have them in the Report's module.
>
>
>
Quote:
|
Also see my reply direct to your email.
|
>
I don't think it made it. *Sald may mix with oil and vinegar but there's
not such email address as far as I know.
>
Remember, I created a text box in the Report header band. *I have
* * * * =NZ([Reports]![Report1].[OpenArgs],"0")
as the Control source (under data tab of property sheet). *You need to
change Report1 to your report's name.
>
In the footer band I put another textbox at the bottom to print the message.
* *=IIf([Text1]="1","Customer",IIf([Text1]="2","Account","File"))
You need to change Text1 to the name of the Textbox in the Report header.
>
>
>>
Here's another thing you could do. *Forget the first textbox...put the
second text box at the footer. *Now open the code module for the report
and put this code into it.
>
Private Function GetCopyText() As String
* * * * 'if no argument passed default to "File". *Press F1
* * * * 'on the word NZ for help if necessary.
* * * * Select Case NZ(Me.OpenArgs,3)
* * * * Case 1
* * * * * * * * GetCopyText = "Customer"
* * * * Case 2
* * * * * * * * GetCopyText = "Accounts"
* * * * Case Else
* * * * * * * * GetCopyText = "File"
* * * * End Select
* * * * GetCopyText = GetCopyText & " Copy - Print "
* * * * GetCopyText = GetCopyText & NZ(Me.OpenArgs,3)
End Function
>
Now in the ControlSource for the textbox in the report's page footer enter
* * * * =GetCopyText()
This will call the function GetCopyText and print the result in the footer..
>
Either way works.
>
Feels Goodhttp://www.youtube.com/watch?v=xA4lPE4MI6A&NR=1- Hide quotedtext -
>
- Show quoted text -
|
Thanks for your help.
I moved the the lines of code to the button on the Form and it
generates the printouts.
The query I've generated prompts the user to enter an invoice number,
to gather the information for the report.
When I print invoice, the reports are generated but I have to enter
the invoice number three times.
Do you know how I can reduce this to entering only once ?
Thanks again.
|

June 27th, 2008, 08:22 PM
|
|
|
Re: Print a report 3 times with 3 different fields visible
Studiotyphoon wrote:
Quote:
On Apr 21, 4:29 pm, Salad <o...@vinegar.comwrote:
>
Quote:
>>Studiotyphoon wrote:
>>
Quote:
|
>>>On Apr 19, 8:51 pm, Salad <o...@vinegar.comwrote:
|
>>>>>>
Quote:
>>>>>I have report which I need to print 3 times, but would like to have
>>>>>the following headings
|
>>
Quote:
>>>>>Customer Copy - Print 1
>>>>>Accounts Copy - Print 2
>>>>>File Copy -Print 3
|
>>
Quote:
>>>>>I created a macro to print the report three times, but do not know how
>>>>>I can display each text field for each print.
|
>>
Quote:
|
>>>>>Can anybody point me in the right direction.
|
>>
Quote:
>>>>What version of Access are you using? There is an OpenArgs parameter
>>>>you can pass to the report in A2003. Ex:
>>> DoCmd.OpenReport "YourReportName", , , , , "1"
>>> DoCmd.OpenReport "YourReportName", , , , , "2"
>>> DoCmd.OpenReport "YourReportName", , , , , "3"
|
>>
Quote:
>>>>The 1,2,3 is the argument. I created a report called Report1. I
>>>>created 2 text boxes; Text1 and Text2. I put Text1 in the report's
>>>>header, visible = False. I put Text2 in the Report footer.
|
>>
Quote:
>>>>In Text1 I entered, for the ControlSource in the Data tab,
>>> =NZ([Reports]![Report1].[OpenArgs],"0")
>>>>as Report1 is the name of the report.
|
>>
Quote:
>>>>In Text2 I entered
>>> =IIf([Text1]="1","Customer",IIf([Text1]="2","Account","File")) & " Copy"
>>>>in the control source.
|
>>
Quote:
>>>>Now when I run the report, depending on the argument passed, it prints
>>>>the value I want.
|
>>
Quote:
|
>>>>Fireballshttp://www.youtube.com/watch?v=uzkNI4YIU2o
|
>>
Quote:
|
>>>Thanks for help so far.
|
>>
Quote:
|
>>>Running Access 2003, SP2
|
>>
Quote:
|
>>>But still struggling to get it to work.
|
>>
Quote:
|
>>>I've added the following into the report under On Open Event
|
>>
Quote:
>>> DoCmd.OpenReport "YourReportName", , , , , "1"
>>> DoCmd.OpenReport "YourReportName", , , , , "2"
>>> DoCmd.OpenReport "YourReportName", , , , , "3"
|
>>
Quote:
>>>When I try running the report it comes up with an error against the
>>>first line of the code.
|
>>
>>I don't use macros. I checked the Macro builder and there's no OpenArgs
>>capability with them. I suppose you could use RunCode and in a code
>>module put the OpenReport lines in the sub.
>>
>>Did you change "YourReportName" to the name of your report?
>>
>>
Quote:
|
>>>Should this code be in the report or Form for the OpenArgs to be used.
|
>>
>>Usually I call reports from a form. I might have a command button
>>CommandReport with a caption of "Report". In the OnClick event I would
>>have those 3 lines. I would not have them in the Report's module.
>>
>>
>>
>>
Quote:
|
>>>Also see my reply direct to your email.
|
>>
>>I don't think it made it. Sald may mix with oil and vinegar but there's
>>not such email address as far as I know.
>>
>>Remember, I created a text box in the Report header band. I have
> =NZ([Reports]![Report1].[OpenArgs],"0")
>>as the Control source (under data tab of property sheet). You need to
>>change Report1 to your report's name.
>>
>>In the footer band I put another textbox at the bottom to print the message.
> =IIf([Text1]="1","Customer",IIf([Text1]="2","Account","File"))
>>You need to change Text1 to the name of the Textbox in the Report header.
>>
>>
>>
>>>>
>>Here's another thing you could do. Forget the first textbox...put the
>>second text box at the footer. Now open the code module for the report
>>and put this code into it.
>>
>>Private Function GetCopyText() As String
> 'if no argument passed default to "File". Press F1
> 'on the word NZ for help if necessary.
> Select Case NZ(Me.OpenArgs,3)
> Case 1
> GetCopyText = "Customer"
> Case 2
> GetCopyText = "Accounts"
> Case Else
> GetCopyText = "File"
> End Select
> GetCopyText = GetCopyText & " Copy - Print "
> GetCopyText = GetCopyText & NZ(Me.OpenArgs,3)
>>End Function
>>
>>Now in the ControlSource for the textbox in the report's page footer enter
> =GetCopyText()
>>This will call the function GetCopyText and print the result in the footer.
>>
>>Either way works.
>>
>>Feels Goodhttp://www.youtube.com/watch?v=xA4lPE4MI6A&NR=1- Hide quoted text -
>>
>>- Show quoted text -
|
>
>
Thanks for your help.
>
I moved the the lines of code to the button on the Form and it
generates the printouts.
>
The query I've generated prompts the user to enter an invoice number,
to gather the information for the report.
When I print invoice, the reports are generated but I have to enter
the invoice number three times.
>
Do you know how I can reduce this to entering only once ?
>
Thanks again.
|
The easist way I know to do that is to create a TextBox on the form and
allow the user to enter an invoice number. Then when you print the
report by pressing the Report command button do something like
Private Sub CommandReport_Click()
If Not IsNull(Me.InvoiceNumber) Then
...print report(s)
Else
msgbox "Please supply an invoice number."
Me.InvoiceNumber.SetFocus
Endif
End Sub
Now lets say that this form is called Form1. Open up the query in
design mode and under the InvoiceNumber column in the Criteria row enter
Forms!Form1!InvoiceNumber
You'd want to change Form1 to whatever formname you have.
Now what happens if you print all three reports and the first one prints
OK and then jams on the 2nd or 3rd report. You could create an Option
group with 4 options; 0 = All, 1 = Cust, 2 = Accounts, 3 = File.
Default value (under Data tab) is 0, name of option group is Frame1.
Then when you print your code could be something like
Private Sub CommandReport_Click()
Dim intFor As Integer
If Not IsNull(Me.InvoiceNumber) Then
If Me.Frame1 <0 then
Docmd.OpenReport "YourReport",,,,,Me.Frame1
Else
For intFor = 1 to 3
Docmd.OpenReport "YourReport",,,,,intFor
Next
Else
msgbox "Please supply an invoice number."
Me.InvoiceNumber.SetFocus
Endif
End Sub
Destination Unknown
http://www.youtube.com/watch?v=uitCCcLAtGw
|

June 27th, 2008, 08:23 PM
|
|
|
Re: Print a report 3 times with 3 different fields visible
On Apr 21, 10:49*pm, Salad <o...@vinegar.comwrote:
Quote:
Studiotyphoon wrote:
Quote:
|
On Apr 21, 4:29 pm, Salad <o...@vinegar.comwrote:
|
>>
Quote:
Quote:
|
>>On Apr 19, 8:51 pm, Salad <o...@vinegar.comwrote:
|
|
>>>
Quote:
Quote:
>>>>I have report which I need to print 3 times, but would like to have
>>>>the following headings
|
|
>
Quote:
Quote:
>>>>Customer Copy - Print 1
>>>>Accounts Copy - Print 2
>>>>File Copy -Print 3
|
|
>
Quote:
Quote:
>>>>I created a macro to print the report three times, but do not know how
>>>>I can display each text field for each print.
|
|
>
Quote:
Quote:
|
>>>>Can anybody point me in the right direction.
|
|
>
Quote:
Quote:
>>>What version of Access are you using? *There is an OpenArgs parameter
>>>you can pass to the report in A2003. *Ex:
>>* * * DoCmd.OpenReport "YourReportName", , , , , "1"
>>* * * DoCmd.OpenReport "YourReportName", , , , , "2"
>>* * * DoCmd.OpenReport "YourReportName", , , , , "3"
|
|
>
Quote:
Quote:
>>>The 1,2,3 is the argument. *I created a report called Report1. *I
>>>created 2 text boxes; Text1 and Text2. *I put Text1 in the report's
>>>header, visible = False. *I put Text2 in the Report footer.
|
|
>
Quote:
Quote:
>>>In Text1 I entered, for the ControlSource in the Data tab,
>>* * * =NZ([Reports]![Report1].[OpenArgs],"0")
>>>as Report1 is the name of the report.
|
|
>
Quote:
Quote:
>>>In Text2 I entered
>>* * * =IIf([Text1]="1","Customer",IIf([Text1]="2","Account","File")) & " Copy" * * * *
>>>in the control source.
|
|
>
Quote:
Quote:
>>>Now when I run the report, depending on the argument passed, it prints
>>>the value I want.
|
|
>
Quote:
Quote:
|
>>>Fireballshttp://www.youtube.com/watch?v=uzkNI4YIU2o
|
|
>
Quote:
Quote:
|
>>Thanks for help so far.
|
|
>
Quote:
Quote:
|
>>Running Access 2003, SP2
|
|
>
Quote:
Quote:
|
>>But still struggling to get it to work.
|
|
>
Quote:
Quote:
|
>>I've added the following into the report under On Open Event
|
|
>
Quote:
Quote:
>>* * * DoCmd.OpenReport "YourReportName", , , , , "1"
>>* * * DoCmd.OpenReport "YourReportName", , , , , "2"
>>* * * DoCmd.OpenReport "YourReportName", , , , , "3"
|
|
>
Quote:
Quote:
>>When I try running the report it comes up with an error against the
>>first line of the code.
|
|
>
Quote:
Quote:
>I don't use macros. *I checked the Macro builder and there's no OpenArgs
>capability with them. *I suppose you could use RunCode and in a code
>module put the OpenReport lines in the sub.
|
|
>
Quote:
Quote:
|
>Did you change "YourReportName" to the name of your report?
|
|
>
Quote:
Quote:
|
>>Should this code be in the report or Form for the OpenArgs to be used.
|
|
>
Quote:
Quote:
>Usually I call reports from a form. *I might have a command button
>CommandReport with a caption of "Report". *In the OnClick event I would
>have those 3 lines. *I would not have them in the Report's module.
|
|
>
Quote:
Quote:
|
>>Also see my reply direct to your email.
|
|
>
Quote:
Quote:
>I don't think it made it. *Sald may mix with oil and vinegar but there's
>not such email address as far as I know.
|
|
>
Quote:
Quote:
>Remember, I created a text box in the Report header band. *I have
* * * *=NZ([Reports]![Report1].[OpenArgs],"0")
>as the Control source (under data tab of property sheet). *You need to
>change Report1 to your report's name.
|
|
>
Quote:
Quote:
>In the footer band I put another textbox at the bottom to print the message.
* =IIf([Text1]="1","Customer",IIf([Text1]="2","Account","File"))
>You need to change Text1 to the name of the Textbox in the Report header..
|
|
>>
Quote:
Quote:
>Here's another thing you could do. *Forget the first textbox...put the
>second text box at the footer. *Now open the code module for the report
>and put this code into it.
|
|
>
Quote:
Quote:
>Private Function GetCopyText() As String
* * * *'if no argument passed default to "File". *Press F1
* * * *'on the word NZ for help if necessary.
* * * *Select Case NZ(Me.OpenArgs,3)
* * * *Case 1
* * * * * * * *GetCopyText = "Customer"
* * * *Case 2
* * * * * * * *GetCopyText = "Accounts"
* * * *Case Else
* * * * * * * *GetCopyText = "File"
* * * *End Select
* * * *GetCopyText = GetCopyText & " Copy - Print "
* * * *GetCopyText = GetCopyText & NZ(Me.OpenArgs,3)
>End Function
|
|
>
Quote:
Quote:
>Now in the ControlSource for the textbox in the report's page footer enter
* * * *=GetCopyText()
>This will call the function GetCopyText and print the result in the footer.
|
|
>>
Quote:
Quote:
|
>Feels Goodhttp://www.youtube.com/watch?v=xA4lPE4MI6A&NR=1-Hide quoted text -
|
|
>>>
Quote:
I moved the the lines of code to the button on the Form and it
generates the printouts.
|
>
Quote:
The query I've generated prompts the user to enter an invoice number,
to gather the information for the report.
When I print invoice, the reports are generated but I have to enter
the invoice number three times.
|
>
Quote:
|
Do you know how I can reduce this to entering only once ?
|
>>
The easist way I know to do that is to create a TextBox on the form and
allow the user to enter an invoice number. *Then when you print the
report by pressing the Report command button do something like
* *Private Sub CommandReport_Click()
* * * * If Not IsNull(Me.InvoiceNumber) Then
* * * * * * * * ...print report(s)
* * * * Else
* * * * * * * * msgbox "Please supply an invoice number."
* * * * * * * * Me.InvoiceNumber.SetFocus
* * * * Endif
* *End Sub
>
Now lets say that this form is called Form1. *Open up the query in
design mode and under the InvoiceNumber column in the Criteria row enter
* * * * Forms!Form1!InvoiceNumber
You'd want to change Form1 to whatever formname you have.
>
Now what happens if you print all three reports and the first one prints
OK and then jams on the 2nd or 3rd report. *You could create an Option
group with 4 options; 0 = All, 1 = Cust, 2 = Accounts, 3 = File.
Default value (under Data tab) is 0, name of option group is Frame1.
Then when you print your code could be something like
* *Private Sub CommandReport_Click()
* * * * Dim intFor As Integer
* * * * If Not IsNull(Me.InvoiceNumber) Then
* * * * * * * * If Me.Frame1 <0 then
* * * * * * * * * * * * Docmd.OpenReport "YourReport",,,,,Me.Frame1
* * * * * * * * Else
* * * * * * * * * For intFor = 1 to 3
* * * * * * * * * * * * Docmd.OpenReport "YourReport",,,,,intFor
* * * * * * * * * Next * * * * * * * * * * * * *
* * * * Else
* * * * * * * * msgbox "Please supply an invoice number."
* * * * * * * * Me.InvoiceNumber.SetFocus
* * * * Endif
* *End Sub
>
Destination Unknownhttp://www.youtube.com/watch?v=uitCCcLAtGw- Hide quoted text -
>
- Show quoted text -
|
Thank you for your help.
It has been gratelly appreciated.
|

June 27th, 2008, 08:23 PM
|
|
|
Re: Print a report 3 times with 3 different fields visible
On Apr 22, 11:07*am, Studiotyphoon <a...@pidesign.co.ukwrote:
Quote:
On Apr 21, 10:49*pm, Salad <o...@vinegar.comwrote:
>
>
>
>
>
Quote:
Studiotyphoon wrote:
Quote:
|
On Apr 21, 4:29 pm, Salad <o...@vinegar.comwrote:
|
|
>>
Quote:
Quote:
|
>>>On Apr 19, 8:51 pm, Salad <o...@vinegar.comwrote:
|
|
>>>
Quote:
Quote:
>>>>>I have report which I need to print 3 times, but would like to have
>>>>>the following headings
|
|
>
Quote:
Quote:
>>>>>Customer Copy - Print 1
>>>>>Accounts Copy - Print 2
>>>>>File Copy -Print 3
|
|
>
Quote:
Quote:
>>>>>I created a macro to print the report three times, but do not know how
>>>>>I can display each text field for each print.
|
|
>
Quote:
Quote:
|
>>>>>Can anybody point me in the right direction.
|
|
>
Quote:
Quote:
>>>>What version of Access are you using? *There is an OpenArgs parameter
>>>>you can pass to the report in A2003. *Ex:
>>>* * * DoCmd.OpenReport "YourReportName", , , , , "1"
>>>* * * DoCmd.OpenReport "YourReportName", , , , , "2"
>>>* * * DoCmd.OpenReport "YourReportName", , , , , "3"
|
|
>
Quote:
Quote:
>>>>The 1,2,3 is the argument. *I created a report called Report1. *I
>>>>created 2 text boxes; Text1 and Text2. *I put Text1 in the report's
>>>>header, visible = False. *I put Text2 in the Report footer.
|
|
>
Quote:
Quote:
>>>>In Text1 I entered, for the ControlSource in the Data tab,
>>>* * * =NZ([Reports]![Report1].[OpenArgs],"0")
>>>>as Report1 is the name of the report.
|
|
>
Quote:
Quote:
>>>>In Text2 I entered
>>>* * * =IIf([Text1]="1","Customer",IIf([Text1]="2","Account","File")) & " Copy" * * * *
>>>>in the control source.
|
|
>
Quote:
Quote:
>>>>Now when I run the report, depending on the argument passed, it prints
>>>>the value I want.
|
|
>
Quote:
Quote:
|
>>>>Fireballshttp://www.youtube.com/watch?v=uzkNI4YIU2o
|
|
>
Quote:
Quote:
|
>>>Thanks for help so far.
|
|
>
Quote:
Quote:
|
>>>Running Access 2003, SP2
|
|
>
Quote:
Quote:
|
>>>But still struggling to get it to work.
|
|
>
Quote:
Quote:
|
>>>I've added the following into the report under On Open Event
|
|
>
Quote:
Quote:
>>>* * * DoCmd.OpenReport "YourReportName", , , , , "1"
>>>* * * DoCmd.OpenReport "YourReportName", , , , , "2"
>>>* * * DoCmd.OpenReport "YourReportName", , , , , "3"
|
|
>
Quote:
Quote:
>>>When I try running the report it comes up with an error against the
>>>first line of the code.
|
|
>
Quote:
Quote:
>>I don't use macros. *I checked the Macro builder and there's no OpenArgs
>>capability with them. *I suppose you could use RunCode and in a code
>>module put the OpenReport lines in the sub.
|
|
>
Quote:
Quote:
|
>>Did you change "YourReportName" to the name of your report?
|
|
>
Quote:
Quote:
|
>>>Should this code be in the report or Form for the OpenArgs to be used..
|
|
>
Quote:
Quote:
>>Usually I call reports from a form. *I might have a command button
>>CommandReport with a caption of "Report". *In the OnClick event I would
>>have those 3 lines. *I would not have them in the Report's module.
|
|
>
Quote:
Quote:
|
>>>Also see my reply direct to your email.
|
|
>
Quote:
Quote:
>>I don't think it made it. *Sald may mix with oil and vinegar but there's
>>not such email address as far as I know.
|
|
>
Quote:
Quote:
>>Remember, I created a text box in the Report header band. *I have
>* * * *=NZ([Reports]![Report1].[OpenArgs],"0")
>>as the Control source (under data tab of property sheet). *You need to
>>change Report1 to your report's name.
|
|
>
Quote:
Quote:
>>In the footer band I put another textbox at the bottom to print the message.
>* =IIf([Text1]="1","Customer",IIf([Text1]="2","Account","File"))
>>You need to change Text1 to the name of the Textbox in the Report header.
|
|
>>
Quote:
Quote:
>>Here's another thing you could do. *Forget the first textbox...put the
>>second text box at the footer. *Now open the code module for the report
>>and put this code into it.
|
|
>
Quote:
Quote:
>>Private Function GetCopyText() As String
>* * * *'if no argument passed default to "File". *Press F1
>* * * *'on the word NZ for help if necessary.
>* * * *Select Case NZ(Me.OpenArgs,3)
>* * * *Case 1
>* * * * * * * *GetCopyText = "Customer"
>* * * *Case 2
>* * * * * * * *GetCopyText = "Accounts"
>* * * *Case Else
>* * * * * * * *GetCopyText = "File"
>* * * *End Select
>* * * *GetCopyText = GetCopyText & " Copy - Print "
>* * * *GetCopyText = GetCopyText & NZ(Me.OpenArgs,3)
>>End Function
|
|
>
Quote:
Quote:
>>Now in the ControlSource for the textbox in the report's page footer enter
>* * * *=GetCopyText()
>>This will call the function GetCopyText and print the result in the footer.
|
|
>>
Quote:
Quote:
|
>>Feels Goodhttp://www.youtube.com/watch?v=xA4lPE4MI6A&NR=1-Hidequoted text -
|
|
>>>
Quote:
Quote:
I moved the the lines of code to the button on the Form and it
generates the printouts.
|
|
| | | |