Print a report 3 times with 3 different fields visible

Print a report 3 times with 3 different fields visible

am 19.04.2008 20:38:42 von Studiotyphoon

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.

Re: Print a report 3 times with 3 different fields visible

am 19.04.2008 21:51:10 von Salad

Studiotyphoon wrote:
> 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

Re: Print a report 3 times with 3 different fields visible

am 21.04.2008 13:52:08 von Studiotyphoon

On Apr 19, 8:51=A0pm, Salad wrote:
> Studiotyphoon wrote:
> > 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? =A0There is an OpenArgs parameter
> you can pass to the report in A2003. =A0Ex:
> =A0 =A0 =A0 =A0 DoCmd.OpenReport "YourReportName", , , , , "1"
> =A0 =A0 =A0 =A0 DoCmd.OpenReport "YourReportName", , , , , "2"
> =A0 =A0 =A0 =A0 DoCmd.OpenReport "YourReportName", , , , , "3"
>
> The 1,2,3 is the argument. =A0I created a report called Report1. =A0I
> created 2 text boxes; Text1 and Text2. =A0I put Text1 in the report's
> header, visible =3D False. =A0I put Text2 in the Report footer.
>
> In Text1 I entered, for the ControlSource in the Data tab,
> =A0 =A0 =A0 =A0 =3DNZ([Reports]![Report1].[OpenArgs],"0")
> as Report1 is the name of the report.
>
> In Text2 I entered
> =A0 =A0 =A0 =A0 =3DIIf([Text1]=3D"1","Customer",IIf([Text1]=3D"2","Account=
","File")) & " Copy" =A0 =A0 =A0 =A0
> 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=3DuzkNI4YIU2o

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

> 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 -

Re: Print a report 3 times with 3 different fields visible

am 21.04.2008 17:29:01 von Salad

Studiotyphoon wrote:
> On Apr 19, 8:51 pm, Salad wrote:
>
>>Studiotyphoon wrote:
>>
>>>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.
>>
>>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
>
>
>> 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?

> 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.

>
> 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.

>
> Thanks in advance -
>
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

Re: Print a report 3 times with 3 different fields visible

am 21.04.2008 21:06:21 von Studiotyphoon

On Apr 21, 4:29=A0pm, Salad wrote:
> Studiotyphoon wrote:
> > On Apr 19, 8:51 pm, Salad wrote:
>
> >>Studiotyphoon wrote:
>
> >>>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? =A0There is an OpenArgs parameter
> >>you can pass to the report in A2003. =A0Ex:
> >> =A0 =A0 =A0 =A0DoCmd.OpenReport "YourReportName", , , , , "1"
> >> =A0 =A0 =A0 =A0DoCmd.OpenReport "YourReportName", , , , , "2"
> >> =A0 =A0 =A0 =A0DoCmd.OpenReport "YourReportName", , , , , "3"
>
> >>The 1,2,3 is the argument. =A0I created a report called Report1. =A0I
> >>created 2 text boxes; Text1 and Text2. =A0I put Text1 in the report's
> >>header, visible =3D False. =A0I put Text2 in the Report footer.
>
> >>In Text1 I entered, for the ControlSource in the Data tab,
> >> =A0 =A0 =A0  =NZ([Reports]![Report1].[OpenArgs],"0")
> >>as Report1 is the name of the report.
>
> >>In Text2 I entered
> >> =A0 =A0 =A0  =IIf([Text1]=3D"1","Customer",IIf([Text1]=3D"2","Accou=
nt","File")) & " Copy" =A0 =A0 =A0 =A0
> >>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=3DuzkNI4YIU2o
>
> > 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
>
> >> =A0 =A0 =A0 =A0DoCmd.OpenReport "YourReportName", , , , , "1"
> >> =A0 =A0 =A0 =A0DoCmd.OpenReport "YourReportName", , , , , "2"
> >> =A0 =A0 =A0 =A0DoCmd.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. =A0I checked the Macro builder and there's no OpenArgs=

> capability with them. =A0I 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?
>
> > Should this code be in the report or Form for the OpenArgs to be used.
>
> Usually I call reports from a form. =A0I might have a command button
> CommandReport with a caption of "Report". =A0In the OnClick event I would
> have those 3 lines. =A0I would not have them in the Report's module.
>
>
>
> > Also see my reply direct to your email.
>
> I don't think it made it. =A0Sald 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. =A0I have
> =A0 =A0 =A0 =A0 =3DNZ([Reports]![Report1].[OpenArgs],"0")
> as the Control source (under data tab of property sheet). =A0You need to
> change Report1 to your report's name.
>
> In the footer band I put another textbox at the bottom to print the messag=
e.
> =A0  =IIf([Text1]=3D"1","Customer",IIf([Text1]=3D"2","Accoun t","File")=
)
> You need to change Text1 to the name of the Textbox in the Report header.
>
>
>
> > Thanks in advance -
>
> Here's another thing you could do. =A0Forget the first textbox...put the
> second text box at the footer. =A0Now open the code module for the report
> and put this code into it.
>
> Private Function GetCopyText() As String
> =A0 =A0 =A0 =A0 'if no argument passed default to "File". =A0Press F1
> =A0 =A0 =A0 =A0 'on the word NZ for help if necessary.
> =A0 =A0 =A0 =A0 Select Case NZ(Me.OpenArgs,3)
> =A0 =A0 =A0 =A0 Case 1
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 GetCopyText =3D "Customer"
> =A0 =A0 =A0 =A0 Case 2
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 GetCopyText =3D "Accounts"
> =A0 =A0 =A0 =A0 Case Else
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 GetCopyText =3D "File"
> =A0 =A0 =A0 =A0 End Select
> =A0 =A0 =A0 =A0 GetCopyText =3D GetCopyText & " Copy - Print "
> =A0 =A0 =A0 =A0 GetCopyText =3D GetCopyText & NZ(Me.OpenArgs,3)
> End Function
>
> Now in the ControlSource for the textbox in the report's page footer enter=

> =A0 =A0 =A0 =A0 =3DGetCopyText()
> This will call the function GetCopyText and print the result in the footer=
..
>
> Either way works.
>
> Feels Goodhttp://www.youtube.com/watch?v=3DxA4lPE4MI6A&NR=3D1- 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.

Re: Print a report 3 times with 3 different fields visible

am 21.04.2008 23:49:08 von Salad

Studiotyphoon wrote:

> On Apr 21, 4:29 pm, Salad wrote:
>
>>Studiotyphoon wrote:
>>
>>>On Apr 19, 8:51 pm, Salad wrote:
>>
>>>>Studiotyphoon wrote:
>>
>>>>>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.
>>
>>>>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
>>
>>>> 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?
>>
>>
>>>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.
>>
>>
>>
>>
>>>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.
>>
>>
>>
>>
>>>Thanks in advance -
>>
>>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

Re: Print a report 3 times with 3 different fields visible

am 22.04.2008 12:07:04 von Studiotyphoon

On Apr 21, 10:49=A0pm, Salad wrote:
> Studiotyphoon wrote:
> > On Apr 21, 4:29 pm, Salad wrote:
>
> >>Studiotyphoon wrote:
>
> >>>On Apr 19, 8:51 pm, Salad wrote:
>
> >>>>Studiotyphoon wrote:
>
> >>>>>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 ho=
w
> >>>>>I can display each text field for each print.
>
> >>>>>Can anybody point me in the right direction.
>
> >>>>What version of Access are you using? =A0There is an OpenArgs paramete=
r
> >>>>you can pass to the report in A2003. =A0Ex:
> >>>> =A0 =A0 =A0 DoCmd.OpenReport "YourReportName", , , , , "1"
> >>>> =A0 =A0 =A0 DoCmd.OpenReport "YourReportName", , , , , "2"
> >>>> =A0 =A0 =A0 DoCmd.OpenReport "YourReportName", , , , , "3"
>
> >>>>The 1,2,3 is the argument. =A0I created a report called Report1. =A0I
> >>>>created 2 text boxes; Text1 and Text2. =A0I put Text1 in the report's
> >>>>header, visible =3D False. =A0I put Text2 in the Report footer.
>
> >>>>In Text1 I entered, for the ControlSource in the Data tab,
> >>>> =A0 =A0 =A0 =3DNZ([Reports]![Report1].[OpenArgs],"0")
> >>>>as Report1 is the name of the report.
>
> >>>>In Text2 I entered
> >>>> =A0 =A0 =A0 =3DIIf([Text1]=3D"1","Customer",IIf([Text1]=3D"2","Accoun=
t","File")) & " Copy" =A0 =A0 =A0 =A0
> >>>>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=3DuzkNI4YIU2o
>
> >>>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
>
> >>>> =A0 =A0 =A0 DoCmd.OpenReport "YourReportName", , , , , "1"
> >>>> =A0 =A0 =A0 DoCmd.OpenReport "YourReportName", , , , , "2"
> >>>> =A0 =A0 =A0 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. =A0I checked the Macro builder and there's no OpenAr=
gs
> >>capability with them. =A0I 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?
>
> >>>Should this code be in the report or Form for the OpenArgs to be used.
>
> >>Usually I call reports from a form. =A0I might have a command button
> >>CommandReport with a caption of "Report". =A0In the OnClick event I woul=
d
> >>have those 3 lines. =A0I would not have them in the Report's module.
>
> >>>Also see my reply direct to your email.
>
> >>I don't think it made it. =A0Sald 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. =A0I have
> >> =A0 =A0 =A0  =NZ([Reports]![Report1].[OpenArgs],"0")
> >>as the Control source (under data tab of property sheet). =A0You need to=

> >>change Report1 to your report's name.
>
> >>In the footer band I put another textbox at the bottom to print the mess=
age.
> >> =A0 =3DIIf([Text1]=3D"1","Customer",IIf([Text1]=3D"2","Account", "File")=
)
> >>You need to change Text1 to the name of the Textbox in the Report header=
..
>
> >>>Thanks in advance -
>
> >>Here's another thing you could do. =A0Forget the first textbox...put the=

> >>second text box at the footer. =A0Now open the code module for the repor=
t
> >>and put this code into it.
>
> >>Private Function GetCopyText() As String
> >> =A0 =A0 =A0 =A0'if no argument passed default to "File". =A0Press F1
> >> =A0 =A0 =A0 =A0'on the word NZ for help if necessary.
> >> =A0 =A0 =A0 =A0Select Case NZ(Me.OpenArgs,3)
> >> =A0 =A0 =A0 =A0Case 1
> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0GetCopyText =3D "Customer"
> >> =A0 =A0 =A0 =A0Case 2
> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0GetCopyText =3D "Accounts"
> >> =A0 =A0 =A0 =A0Case Else
> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0GetCopyText =3D "File"
> >> =A0 =A0 =A0 =A0End Select
> >> =A0 =A0 =A0 =A0GetCopyText =3D GetCopyText & " Copy - Print "
> >> =A0 =A0 =A0 =A0GetCopyText =3D GetCopyText & NZ(Me.OpenArgs,3)
> >>End Function
>
> >>Now in the ControlSource for the textbox in the report's page footer ent=
er
> >> =A0 =A0 =A0  =GetCopyText()
> >>This will call the function GetCopyText and print the result in the foot=
er.
>
> >>Either way works.
>
> >>Feels Goodhttp://www.youtube.com/watch?v=3DxA4lPE4MI6A&NR=3D1-Hide quote=
d 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. =A0Then when you print the
> report by pressing the Report command button do something like
> =A0 =A0Private Sub CommandReport_Click()
> =A0 =A0 =A0 =A0 If Not IsNull(Me.InvoiceNumber) Then
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ...print report(s)
> =A0 =A0 =A0 =A0 Else
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 msgbox "Please supply an invoice number."
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Me.InvoiceNumber.SetFocus
> =A0 =A0 =A0 =A0 Endif
> =A0 =A0End Sub
>
> Now lets say that this form is called Form1. =A0Open up the query in
> design mode and under the InvoiceNumber column in the Criteria row enter
> =A0 =A0 =A0 =A0 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. =A0You could create an Option
> group with 4 options; 0 =3D All, 1 =3D Cust, 2 =3D Accounts, 3 =3D File.
> Default value (under Data tab) is 0, name of option group is Frame1.
> Then when you print your code could be something like
> =A0 =A0Private Sub CommandReport_Click()
> =A0 =A0 =A0 =A0 Dim intFor As Integer
> =A0 =A0 =A0 =A0 If Not IsNull(Me.InvoiceNumber) Then
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 If Me.Frame1 <> 0 then
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Docmd.OpenReport "YourRepo=
rt",,,,,Me.Frame1
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Else
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 For intFor =3D 1 to 3
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Docmd.OpenReport "YourRepo=
rt",,,,,intFor
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Next =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0
> =A0 =A0 =A0 =A0 Else
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 msgbox "Please supply an invoice number."
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Me.InvoiceNumber.SetFocus
> =A0 =A0 =A0 =A0 Endif
> =A0 =A0End Sub
>
> Destination Unknownhttp://www.youtube.com/watch?v=3DuitCCcLAtGw- Hide quot=
ed text -
>
> - Show quoted text -

Thank you for your help.

It has been gratelly appreciated.

Re: Print a report 3 times with 3 different fields visible

am 22.04.2008 21:42:25 von Studiotyphoon

On Apr 22, 11:07=A0am, Studiotyphoon wrote:
> On Apr 21, 10:49=A0pm, Salad wrote:
>
>
>
>
>
> > Studiotyphoon wrote:
> > > On Apr 21, 4:29 pm, Salad wrote:
>
> > >>Studiotyphoon wrote:
>
> > >>>On Apr 19, 8:51 pm, Salad wrote:
>
> > >>>>Studiotyphoon wrote:
>
> > >>>>>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? =A0There is an OpenArgs parame=
ter
> > >>>>you can pass to the report in A2003. =A0Ex:
> > >>>> =A0 =A0 =A0 DoCmd.OpenReport "YourReportName", , , , , "1"
> > >>>> =A0 =A0 =A0 DoCmd.OpenReport "YourReportName", , , , , "2"
> > >>>> =A0 =A0 =A0 DoCmd.OpenReport "YourReportName", , , , , "3"
>
> > >>>>The 1,2,3 is the argument. =A0I created a report called Report1. =A0=
I
> > >>>>created 2 text boxes; Text1 and Text2. =A0I put Text1 in the report'=
s
> > >>>>header, visible =3D False. =A0I put Text2 in the Report footer.
>
> > >>>>In Text1 I entered, for the ControlSource in the Data tab,
> > >>>> =A0 =A0 =A0 =3DNZ([Reports]![Report1].[OpenArgs],"0")
> > >>>>as Report1 is the name of the report.
>
> > >>>>In Text2 I entered
> > >>>> =A0 =A0 =A0 =3DIIf([Text1]=3D"1","Customer",IIf([Text1]=3D"2","Acco=
unt","File")) & " Copy" =A0 =A0 =A0 =A0
> > >>>>in the control source.
>
> > >>>>Now when I run the report, depending on the argument passed, it prin=
ts
> > >>>>the value I want.
>
> > >>>>Fireballshttp://www.youtube.com/watch?v=3DuzkNI4YIU2o
>
> > >>>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
>
> > >>>> =A0 =A0 =A0 DoCmd.OpenReport "YourReportName", , , , , "1"
> > >>>> =A0 =A0 =A0 DoCmd.OpenReport "YourReportName", , , , , "2"
> > >>>> =A0 =A0 =A0 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. =A0I checked the Macro builder and there's no Open=
Args
> > >>capability with them. =A0I 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?
>
> > >>>Should this code be in the report or Form for the OpenArgs to be used=
..
>
> > >>Usually I call reports from a form. =A0I might have a command button
> > >>CommandReport with a caption of "Report". =A0In the OnClick event I wo=
uld
> > >>have those 3 lines. =A0I would not have them in the Report's module.
>
> > >>>Also see my reply direct to your email.
>
> > >>I don't think it made it. =A0Sald may mix with oil and vinegar but the=
re's
> > >>not such email address as far as I know.
>
> > >>Remember, I created a text box in the Report header band. =A0I have
> > >> =A0 =A0 =A0  =NZ([Reports]![Report1].[OpenArgs],"0")
> > >>as the Control source (under data tab of property sheet). =A0You need =
to
> > >>change Report1 to your report's name.
>
> > >>In the footer band I put another textbox at the bottom to print the me=
ssage.
> > >> =A0 =3DIIf([Text1]=3D"1","Customer",IIf([Text1]=3D"2","Account", "File=
"))
> > >>You need to change Text1 to the name of the Textbox in the Report head=
er.
>
> > >>>Thanks in advance -
>
> > >>Here's another thing you could do. =A0Forget the first textbox...put t=
he
> > >>second text box at the footer. =A0Now open the code module for the rep=
ort
> > >>and put this code into it.
>
> > >>Private Function GetCopyText() As String
> > >> =A0 =A0 =A0 =A0'if no argument passed default to "File". =A0Press F1
> > >> =A0 =A0 =A0 =A0'on the word NZ for help if necessary.
> > >> =A0 =A0 =A0 =A0Select Case NZ(Me.OpenArgs,3)
> > >> =A0 =A0 =A0 =A0Case 1
> > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0GetCopyText =3D "Customer"
> > >> =A0 =A0 =A0 =A0Case 2
> > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0GetCopyText =3D "Accounts"
> > >> =A0 =A0 =A0 =A0Case Else
> > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0GetCopyText =3D "File"
> > >> =A0 =A0 =A0 =A0End Select
> > >> =A0 =A0 =A0 =A0GetCopyText =3D GetCopyText & " Copy - Print "
> > >> =A0 =A0 =A0 =A0GetCopyText =3D GetCopyText & NZ(Me.OpenArgs,3)
> > >>End Function
>
> > >>Now in the ControlSource for the textbox in the report's page footer e=
nter
> > >> =A0 =A0 =A0  =GetCopyText()
> > >>This will call the function GetCopyText and print the result in the fo=
oter.
>
> > >>Either way works.
>
> > >>Feels Goodhttp://www.youtube.com/watch?v=3DxA4lPE4MI6A&NR=3D1-Hide quot=
ed 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. =A0Then when you print the
> > report by pressing the Report command button do something like
> > =A0 =A0Private Sub CommandReport_Click()
> > =A0 =A0 =A0 =A0 If Not IsNull(Me.InvoiceNumber) Then
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ...print report(s)
> > =A0 =A0 =A0 =A0 Else
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 msgbox "Please supply an invoice number.=
"
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Me.InvoiceNumber.SetFocus
> > =A0 =A0 =A0 =A0 Endif
> > =A0 =A0End Sub
>
> > Now lets say that this form is called Form1. =A0Open up the query in
> > design mode and under the InvoiceNumber column in the Criteria row enter=

> > =A0 =A0 =A0 =A0 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. =A0You could create an Option=

> > group with 4 options; 0 =3D All, 1 =3D Cust, 2 =3D Accounts, 3 =3D File.=

> > Default value (under Data tab) is 0, name of option group is Frame1.
> > Then when you print your code could be something like
> > =A0 =A0Private Sub CommandReport_Click()
> > =A0 =A0 =A0 =A0 Dim intFor As Integer
> > =A0 =A0 =A0 =A0 If Not IsNull(Me.InvoiceNumber) Then
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 If Me.Frame1 <> 0 then
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Docmd.OpenReport "YourRe=
port",,,,,Me.Frame1
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Else
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 For intFor =3D 1 to 3
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Docmd.OpenReport "YourRe=
port",,,,,intFor
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Next =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0
> > =A0 =A0 =A0 =A0 Else
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 msgbox "Please supply an invoice number.=
"
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Me.InvoiceNumber.SetFocus
> > =A0 =A0 =A0 =A0 Endif
> > =A0 =A0End Sub
>
> > Destination Unknownhttp://www.youtube.com/watch?v=3DuitCCcLAtGw-Hide quo=
ted text -
>
> > - Show quoted text -
>
> Thank you for your help.
>
> It has been gratelly appreciated.- Hide quoted text -
>
> - Show quoted text -

Hi me again,

With the code you gave me thought problem sorted.

For some reason when I put

Forms!Form1!InvoiceNumber

in the criteria, an error occurred invalid syntax regarding the
expression.

I changed it to the following based upon the help files but I get a
request for a parameter value.

[Forms]![Finance Invoice Form]![Internal ID]

Any Ideas ?

Re: Print a report 3 times with 3 different fields visible

am 23.04.2008 00:35:54 von Salad

Studiotyphoon wrote:

> On Apr 22, 11:07 am, Studiotyphoon wrote:
>
>>On Apr 21, 10:49 pm, Salad wrote:
>>
>>
>>
>>
>>
>>
>>>Studiotyphoon wrote:
>>>
>>>>On Apr 21, 4:29 pm, Salad wrote:
>>
>>>>>Studiotyphoon wrote:
>>
>>>>>>On Apr 19, 8:51 pm, Salad wrote:
>>
>>>>>>>Studiotyphoon wrote:
>>
>>>>>>>>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.
>>
>>>>>>>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
>>
>>>>>>> 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?
>>
>>>>>>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.
>>
>>>>>>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.
>>
>>>>>>Thanks in advance -
>>
>>>>>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-Hidequot ed 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 Unknownhttp://www.youtube.com/watch?v=uitCCcLAtGw-Hide quoted text -
>>
>>>- Show quoted text -
>>
>>Thank you for your help.
>>
>>It has been gratelly appreciated.- Hide quoted text -
>>
>>- Show quoted text -
>
>
> Hi me again,
>
> With the code you gave me thought problem sorted.
>
> For some reason when I put
>
> Forms!Form1!InvoiceNumber
>
> in the criteria, an error occurred invalid syntax regarding the
> expression.
>
> I changed it to the following based upon the help files but I get a
> request for a parameter value.
>
> [Forms]![Finance Invoice Form]![Internal ID]
>
> Any Ideas ?
>

Let's see, select all records from these tables where the invoice number
is equal to an invoice number in...a closed form. I wonder what that
invoice number is?

Are you calling this report form a form's code? Or are you calling it
from the report's recordsource?

I create form's to call reports. I can then provide options, any that I
like, and giving users choices to filter the report, direct the output,
exit without printing, etc.

Re: Print a report 3 times with 3 different fields visible

am 23.04.2008 20:41:36 von Studiotyphoon

On Apr 22, 11:35=A0pm, Salad wrote:
> Studiotyphoon wrote:
> > On Apr 22, 11:07 am, Studiotyphoon wrote:
>
> >>On Apr 21, 10:49 pm, Salad wrote:
>
> >>>Studiotyphoon wrote:
>
> >>>>On Apr 21, 4:29 pm, Salad wrote:
>
> >>>>>Studiotyphoon wrote:
>
> >>>>>>On Apr 19, 8:51 pm, Salad wrote:
>
> >>>>>>>Studiotyphoon wrote:
>
> >>>>>>>>Hi,
>
> >>>>>>>>I have report which I need to print 3 times, but would like to hav=
e
> >>>>>>>>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? =A0There is an OpenArgs param=
eter
> >>>>>>>you can pass to the report in A2003. =A0Ex:
> >>>>>>> =A0 =A0 =A0DoCmd.OpenReport "YourReportName", , , , , "1"
> >>>>>>> =A0 =A0 =A0DoCmd.OpenReport "YourReportName", , , , , "2"
> >>>>>>> =A0 =A0 =A0DoCmd.OpenReport "YourReportName", , , , , "3"
>
> >>>>>>>The 1,2,3 is the argument. =A0I created a report called Report1. =
=A0I
> >>>>>>>created 2 text boxes; Text1 and Text2. =A0I put Text1 in the report=
's
> >>>>>>>header, visible =3D False. =A0I put Text2 in the Report footer.
>
> >>>>>>>In Text1 I entered, for the ControlSource in the Data tab,
> >>>>>>> =A0 =A0  =NZ([Reports]![Report1].[OpenArgs],"0")
> >>>>>>>as Report1 is the name of the report.
>
> >>>>>>>In Text2 I entered
> >>>>>>> =A0 =A0  =IIf([Text1]=3D"1","Customer",IIf([Text1]=3D"2","Acco=
unt","File")) & " Copy" =A0 =A0 =A0 =A0
> >>>>>>>in the control source.
>
> >>>>>>>Now when I run the report, depending on the argument passed, it pri=
nts
> >>>>>>>the value I want.
>
> >>>>>>>Fireballshttp://www.youtube.com/watch?v=3DuzkNI4YIU2o
>
> >>>>>>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
>
> >>>>>>> =A0 =A0 =A0DoCmd.OpenReport "YourReportName", , , , , "1"
> >>>>>>> =A0 =A0 =A0DoCmd.OpenReport "YourReportName", , , , , "2"
> >>>>>>> =A0 =A0 =A0DoCmd.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. =A0I checked the Macro builder and there's no Ope=
nArgs
> >>>>>capability with them. =A0I suppose you could use RunCode and in a cod=
e
> >>>>>module put the OpenReport lines in the sub.
>
> >>>>>Did you change "YourReportName" to the name of your report?
>
> >>>>>>Should this code be in the report or Form for the OpenArgs to be use=
d.
>
> >>>>>Usually I call reports from a form. =A0I might have a command button
> >>>>>CommandReport with a caption of "Report". =A0In the OnClick event I w=
ould
> >>>>>have those 3 lines. =A0I would not have them in the Report's module.
>
> >>>>>>Also see my reply direct to your email.
>
> >>>>>I don't think it made it. =A0Sald may mix with oil and vinegar but th=
ere's
> >>>>>not such email address as far as I know.
>
> >>>>>Remember, I created a text box in the Report header band. =A0I have
> >>>>> =A0 =A0 =A0 =3DNZ([Reports]![Report1].[OpenArgs],"0")
> >>>>>as the Control source (under data tab of property sheet). =A0You need=
to
> >>>>>change Report1 to your report's name.
>
> >>>>>In the footer band I put another textbox at the bottom to print the m=
essage.
> >>>>>  =IIf([Text1]=3D"1","Customer",IIf([Text1]=3D"2","Accoun t","File=
"))
> >>>>>You need to change Text1 to the name of the Textbox in the Report hea=
der.
>
> >>>>>>Thanks in advance -
>
> >>>>>Here's another thing you could do. =A0Forget the first textbox...put =
the
> >>>>>second text box at the footer. =A0Now open the code module for the re=
port
> >>>>>and put this code into it.
>
> >>>>>Private Function GetCopyText() As String
> >>>>> =A0 =A0 =A0 'if no argument passed default to "File". =A0Press F1
> >>>>> =A0 =A0 =A0 'on the word NZ for help if necessary.
> >>>>> =A0 =A0 =A0 Select Case NZ(Me.OpenArgs,3)
> >>>>> =A0 =A0 =A0 Case 1
> >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 GetCopyText =3D "Customer"
> >>>>> =A0 =A0 =A0 Case 2
> >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 GetCopyText =3D "Accounts"
> >>>>> =A0 =A0 =A0 Case Else
> >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 GetCopyText =3D "File"
> >>>>> =A0 =A0 =A0 End Select
> >>>>> =A0 =A0 =A0 GetCopyText =3D GetCopyText & " Copy - Print "
> >>>>> =A0 =A0 =A0 GetCopyText =3D GetCopyText & NZ(Me.OpenArgs,3)
> >>>>>End Function
>
> >>>>>Now in the ControlSource for the textbox in the report's page footer =
enter
> >>>>> =A0 =A0 =A0 =3DGetCopyText()
> >>>>>This will call the function GetCopyText and print the result in the f=
ooter.
>
> >>>>>Either way works.
>
> >>>>>Feels Goodhttp://www.youtube.com/watch?v=3DxA4lPE4MI6A&NR=3D1-Hide quo=
tedtext -
>
> >>>>>- 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. =A0Then when you print the
> >>>report by pressing the Report command button do something like
> >>> =A0 Private Sub CommandReport_Click()
> >>> =A0 =A0 =A0 =A0If Not IsNull(Me.InvoiceNumber) Then
> >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0...print report(s)
> >>> =A0 =A0 =A0 =A0Else
> >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0msgbox "Please supply an invoice number=
.."
> >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Me.InvoiceNumber.SetFocus
> >>> =A0 =A0 =A0 =A0Endif
> >>> =A0 End Sub
>
> >>>Now lets say that this form is called Form1. =A0Open up the query in
> >>>design mode and under the InvoiceNumber column in the Criteria row ente=
r
> >>> =A0 =A0 =A0 =A0Forms!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 print=
s
> >>>OK and then jams on the 2nd or 3rd report. =A0You could create an Optio=
n
> >>>group with 4 options; 0 =3D All, 1 =3D Cust, 2 =3D Accounts, 3 =3D File=
..
> >>>Default value (under Data tab) is 0, name of option group is Frame1.
> >>>Then when you print your code could be something like
> >>> =A0 Private Sub CommandReport_Click()
> >>> =A0 =A0 =A0 =A0Dim intFor As Integer
> >>> =A0 =A0 =A0 =A0If Not IsNull(Me.InvoiceNumber) Then
> >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0If Me.Frame1 <> 0 then
> >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Docmd.OpenReport "YourR=
eport",,,,,Me.Frame1
> >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Else
> >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0For intFor =3D 1 to 3
> >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Docmd.OpenReport "YourR=
eport",,,,,intFor
> >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Next =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0
> >>> =A0 =A0 =A0 =A0Else
> >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0msgbox "Please supply an invoice number=
.."
> >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Me.InvoiceNumber.SetFocus
> >>> =A0 =A0 =A0 =A0Endif
> >>> =A0 End Sub
>
> >>>Destination Unknownhttp://www.youtube.com/watch?v=3DuitCCcLAtGw-Hidequo=
ted text -
>
> >>>- Show quoted text -
>
> >>Thank you for your help.
>
> >>It has been gratelly appreciated.- Hide quoted text -
>
> >>- Show quoted text -
>
> > Hi me again,
>
> > With the code you gave me thought problem sorted.
>
> > For some reason when I put
>
> > Forms!Form1!InvoiceNumber
>
> > in the criteria, an error occurred =A0invalid syntax regarding the
> > expression.
>
> > I changed it to the following based upon the help files but I get a
> > request for a parameter value.
>
> > [Forms]![Finance Invoice Form]![Internal ID]
>
> > Any Ideas ?
>
> Let's see, select all records from these tables where the invoice number
> is equal to an invoice number in...a closed form. =A0I wonder what that
> invoice number is?
>
> Are you calling this report form a form's code? =A0Or are you calling it
> from the report's recordsource?
>
> I create form's to call reports. =A0I can then provide options, any that I=

> like, and giving users choices to filter the report, direct the output,
> exit without printing, etc.- Hide quoted text -
>
> - Show quoted text -

I have a Subform called invoicing, which is then linked to a header
Form.

I placed your code in the subform Invoicing and without entering the
code into the query, the report prints out all invoices it can find,
and three times as per the above code.

it would be fine if I wanted to print all invoices, but when I only
want to select the current invoice record using the code in the
criteria, I get a data mismatch when I try to print.

I can email a copy of the Database for you to look at and point me in
the right direction, if it help resolve the problem.

Thanks

Re: Print a report 3 times with 3 different fields visible

am 23.04.2008 22:13:37 von Salad

Studiotyphoon wrote:

> On Apr 22, 11:35 pm, Salad wrote:
>
>>Studiotyphoon wrote:
>>
>>>On Apr 22, 11:07 am, Studiotyphoon wrote:
>>
>>>>On Apr 21, 10:49 pm, Salad wrote:
>>
>>>>>Studiotyphoon wrote:
>>
>>>>>>On Apr 21, 4:29 pm, Salad wrote:
>>
>>>>>>>Studiotyphoon wrote:
>>
>>>>>>>>On Apr 19, 8:51 pm, Salad wrote:
>>
>>>>>>>>>Studiotyphoon wrote:
>>
>>>>>>>>>>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.
>>
>>>>>>>>>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
>>
>>>>>>>>> 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?
>>
>>>>>>>>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.
>>
>>>>>>>>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.
>>
>>>>>>>>Thanks in advance -
>>
>>>>>>>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-Hidequot edtext -
>>
>>>>>>>- 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 Unknownhttp://www.youtube.com/watch?v=uitCCcLAtGw-Hidequoted text -
>>
>>>>>- Show quoted text -
>>
>>>>Thank you for your help.
>>
>>>>It has been gratelly appreciated.- Hide quoted text -
>>
>>>>- Show quoted text -
>>
>>>Hi me again,
>>
>>>With the code you gave me thought problem sorted.
>>
>>>For some reason when I put
>>
>>>Forms!Form1!InvoiceNumber
>>
>>>in the criteria, an error occurred invalid syntax regarding the
>>>expression.
>>
>>>I changed it to the following based upon the help files but I get a
>>>request for a parameter value.
>>
>>>[Forms]![Finance Invoice Form]![Internal ID]
>>
>>>Any Ideas ?
>>
>>Let's see, select all records from these tables where the invoice number
>>is equal to an invoice number in...a closed form. I wonder what that
>>invoice number is?
>>
>>Are you calling this report form a form's code? Or are you calling it
>>from the report's recordsource?
>>
>>I create form's to call reports. I can then provide options, any that I
>>like, and giving users choices to filter the report, direct the output,
>>exit without printing, etc.- Hide quoted text -
>>
>>- Show quoted text -
>
>
> I have a Subform called invoicing, which is then linked to a header
> Form.
>
> I placed your code in the subform Invoicing and without entering the
> code into the query, the report prints out all invoices it can find,
> and three times as per the above code.
>
> it would be fine if I wanted to print all invoices, but when I only
> want to select the current invoice record using the code in the
> criteria, I get a data mismatch when I try to print.
>
> I can email a copy of the Database for you to look at and point me in
> the right direction, if it help resolve the problem.
>
> Thanks

OK. You're in a subform. I have no idea what the invoice number
textbox is called. I'll use InvNum. Substitute InvNum below with
whatever you are using.

First thing. If you pass a number, you don't surround it with anything.
If the invoice number is not a numeric field (look at your table) then
you surround it in quotes.

Now...I'll assume you are sitting on the record WITH the invoice number.

First, open up the query and remove any references to the
Forms!Form!InvNum or [Enter InvNum] in the criteria row.

OK. We have a clean invoice query in the report and whereever.
Now...when you print a report you have various arguments you can pass.
So why not pass the InvNum you are sitting on in the subform?
*if the field InvNum is a number
Docmd.OpenReport "YourReportName",,,"InvNum = " & Me.InvNum,1
Docmd.OpenReport "YourReportName",,,"InvNum = " & Me.InvNum,2
Docmd.OpenReport "YourReportName",,,"InvNum = " & Me.InvNum,3

*if the field InvNum is a text field
Docmd.OpenReport "YourReportName",,,"InvNum = '" & Me.InvNum & "'",1
Docmd.OpenReport "YourReportName",,,"InvNum = '" & Me.InvNum & "'",2
Docmd.OpenReport "YourReportName",,,"InvNum = '" & Me.InvNum & "'",3

Small Potatoes
http://www.youtube.com/watch?v=9azTIoSXbVM

Re: Print a report 3 times with 3 different fields visible

am 23.04.2008 22:23:07 von Studiotyphoon

On Apr 23, 9:13=A0pm, Salad wrote:
> Studiotyphoon wrote:
> > On Apr 22, 11:35 pm, Salad wrote:
>
> >>Studiotyphoon wrote:
>
> >>>On Apr 22, 11:07 am, Studiotyphoon wrote:
>
> >>>>On Apr 21, 10:49 pm, Salad wrote:
>
> >>>>>Studiotyphoon wrote:
>
> >>>>>>On Apr 21, 4:29 pm, Salad wrote:
>
> >>>>>>>Studiotyphoon wrote:
>
> >>>>>>>>On Apr 19, 8:51 pm, Salad wrote:
>
> >>>>>>>>>Studiotyphoon wrote:
>
> >>>>>>>>>>Hi,
>
> >>>>>>>>>>I have report which I need to print 3 times, but would like to h=
ave
> >>>>>>>>>>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 kn=
ow 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? =A0There is an OpenArgs par=
ameter
> >>>>>>>>>you can pass to the report in A2003. =A0Ex:
> >>>>>>>>> =A0 =A0 DoCmd.OpenReport "YourReportName", , , , , "1"
> >>>>>>>>> =A0 =A0 DoCmd.OpenReport "YourReportName", , , , , "2"
> >>>>>>>>> =A0 =A0 DoCmd.OpenReport "YourReportName", , , , , "3"
>
> >>>>>>>>>The 1,2,3 is the argument. =A0I created a report called Report1. =
=A0I
> >>>>>>>>>created 2 text boxes; Text1 and Text2. =A0I put Text1 in the repo=
rt's
> >>>>>>>>>header, visible =3D False. =A0I put Text2 in the Report footer.
>
> >>>>>>>>>In Text1 I entered, for the ControlSource in the Data tab,
> >>>>>>>>> =A0 =A0 =3DNZ([Reports]![Report1].[OpenArgs],"0")
> >>>>>>>>>as Report1 is the name of the report.
>
> >>>>>>>>>In Text2 I entered
> >>>>>>>>> =A0 =A0 =3DIIf([Text1]=3D"1","Customer",IIf([Text1]=3D"2","Accou=
nt","File")) & " Copy" =A0 =A0 =A0 =A0
> >>>>>>>>>in the control source.
>
> >>>>>>>>>Now when I run the report, depending on the argument passed, it p=
rints
> >>>>>>>>>the value I want.
>
> >>>>>>>>>Fireballshttp://www.youtube.com/watch?v=3DuzkNI4YIU 2o
>
> >>>>>>>>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
>
> >>>>>>>>> =A0 =A0 DoCmd.OpenReport "YourReportName", , , , , "1"
> >>>>>>>>> =A0 =A0 DoCmd.OpenReport "YourReportName", , , , , "2"
> >>>>>>>>> =A0 =A0 DoCmd.OpenReport "YourReportName", , , , , "3"
>
> >>>>>>>>When I try running the report it comes up with an error against th=
e
> >>>>>>>>first line of the code.
>
> >>>>>>>I don't use macros. =A0I checked the Macro builder and there's no O=
penArgs
> >>>>>>>capability with them. =A0I suppose you could use RunCode and in a c=
ode
> >>>>>>>module put the OpenReport lines in the sub.
>
> >>>>>>>Did you change "YourReportName" to the name of your report?
>
> >>>>>>>>Should this code be in the report or Form for the OpenArgs to be u=
sed.
>
> >>>>>>>Usually I call reports from a form. =A0I might have a command butto=
n
> >>>>>>>CommandReport with a caption of "Report". =A0In the OnClick event I=
would
> >>>>>>>have those 3 lines. =A0I would not have them in the Report's module=
..
>
> >>>>>>>>Also see my reply direct to your email.
>
> >>>>>>>I don't think it made it. =A0Sald 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. =A0I have=

> >>>>>>> =A0 =A0  =NZ([Reports]![Report1].[OpenArgs],"0")
> >>>>>>>as the Control source (under data tab of property sheet). =A0You ne=
ed to
> >>>>>>>change Report1 to your report's name.
>
> >>>>>>>In the footer band I put another textbox at the bottom to print the=
message.
> >>>>>>> =3DIIf([Text1]=3D"1","Customer",IIf([Text1]=3D"2","Account", "File"=
))
> >>>>>>>You need to change Text1 to the name of the Textbox in the Report h=
eader.
>
> >>>>>>>>Thanks in advance -
>
> >>>>>>>Here's another thing you could do. =A0Forget the first textbox...pu=
t the
> >>>>>>>second text box at the footer. =A0Now open the code module for the =
report
> >>>>>>>and put this code into it.
>
> >>>>>>>Private Function GetCopyText() As String
> >>>>>>> =A0 =A0 =A0'if no argument passed default to "File". =A0Press F1
> >>>>>>> =A0 =A0 =A0'on the word NZ for help if necessary.
> >>>>>>> =A0 =A0 =A0Select Case NZ(Me.OpenArgs,3)
> >>>>>>> =A0 =A0 =A0Case 1
> >>>>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0GetCopyText =3D "Customer"
> >>>>>>> =A0 =A0 =A0Case 2
> >>>>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0GetCopyText =3D "Accounts"
> >>>>>>> =A0 =A0 =A0Case Else
> >>>>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0GetCopyText =3D "File"
> >>>>>>> =A0 =A0 =A0End Select
> >>>>>>> =A0 =A0 =A0GetCopyText =3D GetCopyText & " Copy - Print "
> >>>>>>> =A0 =A0 =A0GetCopyText =3D GetCopyText & NZ(Me.OpenArgs,3)
> >>>>>>>End Function
>
> >>>>>>>Now in the ControlSource for the textbox in the report's page foote=
r enter
> >>>>>>> =A0 =A0  =GetCopyText()
> >>>>>>>This will call the function GetCopyText and print the result in the=
footer.
>
> >>>>>>>Either way works.
>
> >>>>>>>Feels Goodhttp://www.youtube.com/watch?v=3DxA4lPE4MI6A&NR=3D1-Hide q=
uotedtext-
>
> >>>>>>>- 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 a=
nd
> >>>>>allow the user to enter an invoice number. =A0Then when you print the=

> >>>>>report by pressing the Report command button do something like
> >>>>> =A0Private Sub CommandReport_Click()
> >>>>> =A0 =A0 =A0 If Not IsNull(Me.InvoiceNumber) Then
> >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 ...print report(s)
> >>>>> =A0 =A0 =A0 Else
> >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 msgbox "Please supply an invoice number.=
"
> >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 Me.InvoiceNumber.SetFocus
> >>>>> =A0 =A0 =A0 Endif
> >>>>> =A0End Sub
>
> >>>>>Now lets say that this form is called Form1. =A0Open up the query in
> >>>>>design mode and under the InvoiceNumber column in the Criteria row en=
ter
> >>>>> =A0 =A0 =A0 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 pri=
nts
> >>>>>OK and then jams on the 2nd or 3rd report. =A0You could create an Opt=
ion
> >>>>>group with 4 options; 0 =3D All, 1 =3D Cust, 2 =3D Accounts, 3 =3D Fi=
le.
> >>>>>Default value (under Data tab) is 0, name of option group is Frame1.
> >>>>>Then when you print your code could be something like
> >>>>> =A0Private Sub CommandReport_Click()
> >>>>> =A0 =A0 =A0 Dim intFor As Integer
> >>>>> =A0 =A0 =A0 If Not IsNull(Me.InvoiceNumber) Then
> >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 If Me.Frame1 <> 0 then
> >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Docmd.OpenReport "YourRe=
port",,,,,Me.Frame1
> >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 Else
> >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 For intFor =3D 1 to 3
> >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Docmd.OpenReport "YourRe=
port",,,,,intFor
> >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Next =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0
> >>>>> =A0 =A0 =A0 Else
> >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 msgbox "Please supply an invoice number.=
"
> >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 Me.InvoiceNumber.SetFocus
> >>>>> =A0 =A0 =A0 Endif
> >>>>> =A0End Sub
>
> >>>>>Destination Unknownhttp://www.youtube.com/watch?v=3DuitCCcLAtGw-Hideq=
uotedtext -
>
> >>>>>- Show quoted text -
>
> >>>>Thank you for your help.
>
> >>>>It has been gratelly appreciated.- Hide quoted text -
>
> >>>>- Show quoted text -
>
> >>>Hi me again,
>
> >>>With the code you gave me thought problem sorted.
>
> >>>For some reason when I put
>
> >>>Forms!Form1!InvoiceNumber
>
> >>>in the criteria, an error occurred =A0invalid syntax regarding the
> >>>expression.
>
> >>>I changed it to the following based upon the help files but I get a
> >>>request for a parameter value.
>
> >>>[Forms]![Finance Invoice Form]![Internal ID]
>
> >>>Any Ideas ?
>
> >>Let's see, select all records from these tables where the invoice number=

> >>is equal to an invoice number in...a closed form. =A0I wonder what that
> >>invoice number is?
>
> >>Are you calling this report form a form's code? =A0Or are you calling it=

> >>from the report's recordsource?
>
> >>I create form's to call reports. =A0I can then provide options, any that=
I
> >>like, and giving users choices to filter the report, direct the output,
> >>exit without printing, etc.- Hide quoted text -
>
> >>- Show quoted text -
>
> > I have a Subform called invoicing, which is then linked to a header
> > Form.
>
> > I placed your code in the subform Invoicing and without entering the
> > code into the query, the report prints out all invoices it can find,
> > and three times as per the above code.
>
> > it would be fine if I wanted to print all invoices, but when I only
> > want to select the current invoice record using the code in the
> > criteria, I get a data mismatch when I try to print.
>
> > I can email a copy of the Database for you to look at and point me in
> > the right direction, if it help resolve the problem.
>
> > Thanks
>
> OK. =A0You're in a subform. =A0I have no idea what the invoice number
> textbox is called. =A0I'll use InvNum. =A0Substitute InvNum below with
> whatever you are using.
>
> First thing. =A0If you pass a number, you don't surround it with anything.=

> =A0 If the invoice number is not a numeric field (look at your table) then=

> you surround it in quotes.
>
> Now...I'll assume you are sitting on the record WITH the invoice number.
>
> First, open up the query and remove any references to the
> Forms!Form!InvNum or [Enter InvNum] in the criteria row.
>
> OK. =A0We have a clean invoice query in the report and whereever.
> Now...when you print a report you have various arguments you can pass.
> So why not pass the InvNum you are sitting on in the subform?
> =A0 =A0*if the field InvNum is a number
> =A0 =A0Docmd.OpenReport "YourReportName",,,"InvNum =3D " & Me.InvNum,1
> =A0 =A0Docmd.OpenReport "YourReportName",,,"InvNum =3D " & Me.InvNum,2
> =A0 =A0Docmd.OpenReport "YourReportName",,,"InvNum =3D " & Me.InvNum,3
>
> =A0 =A0*if the field InvNum is a text field
> =A0 =A0Docmd.OpenReport "YourReportName",,,"InvNum =3D '" & Me.InvNum & "'=
",1
> =A0 =A0Docmd.OpenReport "YourReportName",,,"InvNum =3D '" & Me.InvNum & "'=
",2
> =A0 =A0Docmd.OpenReport "YourReportName",,,"InvNum =3D '" & Me.InvNum & "'=
",3
>
> Small Potatoes ...
>
> read more =BB- Hide quoted text -
>
> - Show quoted text -

Glad to know there are people like yourself willing to help.

Thanks, It worked a treat.

Re: Print a report 3 times with 3 different fields visible

am 23.04.2008 23:46:26 von Salad

Studiotyphoon wrote:

> On Apr 23, 9:13 pm, Salad wrote:
>
>>Studiotyphoon wrote:
>>
>>>On Apr 22, 11:35 pm, Salad wrote:
>>
>>>>Studiotyphoon wrote:
>>
>>>>>On Apr 22, 11:07 am, Studiotyphoon wrote:
>>
>>>>>>On Apr 21, 10:49 pm, Salad wrote:
>>
>>>>>>>Studiotyphoon wrote:
>>
>>>>>>>>On Apr 21, 4:29 pm, Salad wrote:
>>
>>>>>>>>>Studiotyphoon wrote:
>>
>>>>>>>>>>On Apr 19, 8:51 pm, Salad wrote:
>>
>>>>>>>>>>>Studiotyphoon wrote:
>>
>>>>>>>>>>>>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.
>>
>>>>>>>>>>>Fireballshttp://www.youtube.com/watch?v=uzkNI4YIU 2o
>>
>>>>>>>>>>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
>>
>>>>>>>>>>> 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?
>>
>>>>>>>>>>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.
>>
>>>>>>>>>>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","Accoun t","File"))
>>>>>>>>>You need to change Text1 to the name of the Textbox in the Report header.
>>
>>>>>>>>>>Thanks in advance -
>>
>>>>>>>>>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-Hidequot edtext-
>>
>>>>>>>>>- 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 Unknownhttp://www.youtube.com/watch?v=uitCCcLAtGw-Hidequoted text -
>>
>>>>>>>- Show quoted text -
>>
>>>>>>Thank you for your help.
>>
>>>>>>It has been gratelly appreciated.- Hide quoted text -
>>
>>>>>>- Show quoted text -
>>
>>>>>Hi me again,
>>
>>>>>With the code you gave me thought problem sorted.
>>
>>>>>For some reason when I put
>>
>>>>>Forms!Form1!InvoiceNumber
>>
>>>>>in the criteria, an error occurred invalid syntax regarding the
>>>>>expression.
>>
>>>>>I changed it to the following based upon the help files but I get a
>>>>>request for a parameter value.
>>
>>>>>[Forms]![Finance Invoice Form]![Internal ID]
>>
>>>>>Any Ideas ?
>>
>>>>Let's see, select all records from these tables where the invoice number
>>>>is equal to an invoice number in...a closed form. I wonder what that
>>>>invoice number is?
>>
>>>>Are you calling this report form a form's code? Or are you calling it
>>>
>>>>from the report's recordsource?
>>
>>>>I create form's to call reports. I can then provide options, any that I
>>>>like, and giving users choices to filter the report, direct the output,
>>>>exit without printing, etc.- Hide quoted text -
>>
>>>>- Show quoted text -
>>
>>>I have a Subform called invoicing, which is then linked to a header
>>>Form.
>>
>>>I placed your code in the subform Invoicing and without entering the
>>>code into the query, the report prints out all invoices it can find,
>>>and three times as per the above code.
>>
>>>it would be fine if I wanted to print all invoices, but when I only
>>>want to select the current invoice record using the code in the
>>>criteria, I get a data mismatch when I try to print.
>>
>>>I can email a copy of the Database for you to look at and point me in
>>>the right direction, if it help resolve the problem.
>>
>>>Thanks
>>
>>OK. You're in a subform. I have no idea what the invoice number
>>textbox is called. I'll use InvNum. Substitute InvNum below with
>>whatever you are using.
>>
>>First thing. If you pass a number, you don't surround it with anything.
>> If the invoice number is not a numeric field (look at your table) then
>>you surround it in quotes.
>>
>>Now...I'll assume you are sitting on the record WITH the invoice number.
>>
>>First, open up the query and remove any references to the
>>Forms!Form!InvNum or [Enter InvNum] in the criteria row.
>>
>>OK. We have a clean invoice query in the report and whereever.
>>Now...when you print a report you have various arguments you can pass.
>>So why not pass the InvNum you are sitting on in the subform?
>> *if the field InvNum is a number
>> Docmd.OpenReport "YourReportName",,,"InvNum = " & Me.InvNum,1
>> Docmd.OpenReport "YourReportName",,,"InvNum = " & Me.InvNum,2
>> Docmd.OpenReport "YourReportName",,,"InvNum = " & Me.InvNum,3
>>
>> *if the field InvNum is a text field
>> Docmd.OpenReport "YourReportName",,,"InvNum = '" & Me.InvNum & "'",1
>> Docmd.OpenReport "YourReportName",,,"InvNum = '" & Me.InvNum & "'",2
>> Docmd.OpenReport "YourReportName",,,"InvNum = '" & Me.InvNum & "'",3
>>
>>Small Potatoes ...
>>
>>read more »- Hide quoted text -
>>
>>- Show quoted text -
>
>
> Glad to know there are people like yourself willing to help.
>
> Thanks, It worked a treat.

You got it working? Fantastic!

Hip Hip Hurray :)
http://www.youtube.com/watch?v=bXk5PWs0EEs