Print All Records not just one

  • Thread starter Thread starter Dave Elliott
  • Start date Start date
D

Dave Elliott

I want to print via the option group using option 1 and option 2
For option value 1 print current record
For option value 2 print all records
Below code does not print ALL records for option 2, just one single record

what am I doing wrong?





If PrintCat = 2 Then
DoCmd.OpenReport "Deposits", acNormal
Else: DoCmd.OpenReport "Deposits", acNormal, "", "[RegisterID] =
[Forms]![Deposit Slip]![RegisterID]"
End If
PrintCat = Null
DoCmd.Close acForm, Me.Name
 
What is PrintCat, and when it is assigned a value?
Is it the name of the option group?
What is the OptionValue of the 2nd button? It may not be 2.

To discover why the Else is always executing, try adding:
Debug.Print PrintCat
and see what comes out when the code runs.

The other thing is that the report must be closed when this runs. If it is
already open then the WhereCondition is not applied or altered.
 
PrintCat is the name of the option group
No value assigned to the value of either 1 or two, just on the on click
event of the option group
Report is closed when the code runs.
The idea is to print open report and print one record by choosing option 1
else open report and print all records if option is 2 is chosen

Allen Browne said:
What is PrintCat, and when it is assigned a value?
Is it the name of the option group?
What is the OptionValue of the 2nd button? It may not be 2.

To discover why the Else is always executing, try adding:
Debug.Print PrintCat
and see what comes out when the code runs.

The other thing is that the report must be closed when this runs. If it is
already open then the WhereCondition is not applied or altered.

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

Reply to group, rather than allenbrowne at mvps dot org.

Dave Elliott said:
I want to print via the option group using option 1 and option 2
For option value 1 print current record
For option value 2 print all records
Below code does not print ALL records for option 2, just one single
record

what am I doing wrong?

If PrintCat = 2 Then
DoCmd.OpenReport "Deposits", acNormal
Else: DoCmd.OpenReport "Deposits", acNormal, "", "[RegisterID] =
[Forms]![Deposit Slip]![RegisterID]"
End If
PrintCat = Null
DoCmd.Close acForm, Me.Name
 
Okay, so the trick is to find out why the ELSE is executing.
You can verify that it is by using a BreakPoint.

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

Reply to group, rather than allenbrowne at mvps dot org.

Dave Elliott said:
PrintCat is the name of the option group
No value assigned to the value of either 1 or two, just on the on click
event of the option group
Report is closed when the code runs.
The idea is to print open report and print one record by choosing option
1
else open report and print all records if option is 2 is chosen

Allen Browne said:
What is PrintCat, and when it is assigned a value?
Is it the name of the option group?
What is the OptionValue of the 2nd button? It may not be 2.

To discover why the Else is always executing, try adding:
Debug.Print PrintCat
and see what comes out when the code runs.

The other thing is that the report must be closed when this runs. If it
is already open then the WhereCondition is not applied or altered.


Dave Elliott said:
I want to print via the option group using option 1 and option 2
For option value 1 print current record
For option value 2 print all records
Below code does not print ALL records for option 2, just one single
record

what am I doing wrong?

If PrintCat = 2 Then
DoCmd.OpenReport "Deposits", acNormal
Else: DoCmd.OpenReport "Deposits", acNormal, "", "[RegisterID] =
[Forms]![Deposit Slip]![RegisterID]"
End If
PrintCat = Null
DoCmd.Close acForm, Me.Name
 
Ok, trying this but only printing one record still.
This code is being ran from a form where it opens the report.
Why does it refuse to print all records?

Dim stDocName As String
DoCmd.OpenReport "Deposits", acNormal
PrintCat = Null

If IsNull([Customers]) Or Printed = 0 Then
MsgBox "Payee is Needed and Deposits Must Be Printed"
Customers.SetFocus
Cancel = True
End If
Exit Sub



Allen Browne said:
Okay, so the trick is to find out why the ELSE is executing.
You can verify that it is by using a BreakPoint.

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

Reply to group, rather than allenbrowne at mvps dot org.

Dave Elliott said:
PrintCat is the name of the option group
No value assigned to the value of either 1 or two, just on the on click
event of the option group
Report is closed when the code runs.
The idea is to print open report and print one record by choosing option
1
else open report and print all records if option is 2 is chosen

Allen Browne said:
What is PrintCat, and when it is assigned a value?
Is it the name of the option group?
What is the OptionValue of the 2nd button? It may not be 2.

To discover why the Else is always executing, try adding:
Debug.Print PrintCat
and see what comes out when the code runs.

The other thing is that the report must be closed when this runs. If it
is already open then the WhereCondition is not applied or altered.


I want to print via the option group using option 1 and option 2
For option value 1 print current record
For option value 2 print all records
Below code does not print ALL records for option 2, just one single
record

what am I doing wrong?

If PrintCat = 2 Then
DoCmd.OpenReport "Deposits", acNormal
Else: DoCmd.OpenReport "Deposits", acNormal, "", "[RegisterID] =
[Forms]![Deposit Slip]![RegisterID]"
End If
PrintCat = Null
DoCmd.Close acForm, Me.Name
 
If the line:
DoCmd.OpenReport "Deposits", acNormal
prints only one record, then there is something else that is filtering the
report.

Open the query that feeds the report in design view.
Anything in the criteria that reads the record in the form?

Or is there any code in the report (e.g. its Open event) that applies a
filter?

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

Reply to group, rather than allenbrowne at mvps dot org.

Dave Elliott said:
Ok, trying this but only printing one record still.
This code is being ran from a form where it opens the report.
Why does it refuse to print all records?

Dim stDocName As String
DoCmd.OpenReport "Deposits", acNormal
PrintCat = Null

If IsNull([Customers]) Or Printed = 0 Then
MsgBox "Payee is Needed and Deposits Must Be Printed"
Customers.SetFocus
Cancel = True
End If
Exit Sub



Allen Browne said:
Okay, so the trick is to find out why the ELSE is executing.
You can verify that it is by using a BreakPoint.


Dave Elliott said:
PrintCat is the name of the option group
No value assigned to the value of either 1 or two, just on the on click
event of the option group
Report is closed when the code runs.
The idea is to print open report and print one record by choosing option
1
else open report and print all records if option is 2 is chosen

What is PrintCat, and when it is assigned a value?
Is it the name of the option group?
What is the OptionValue of the 2nd button? It may not be 2.

To discover why the Else is always executing, try adding:
Debug.Print PrintCat
and see what comes out when the code runs.

The other thing is that the report must be closed when this runs. If it
is already open then the WhereCondition is not applied or altered.


I want to print via the option group using option 1 and option 2
For option value 1 print current record
For option value 2 print all records
Below code does not print ALL records for option 2, just one single
record

what am I doing wrong?

If PrintCat = 2 Then
DoCmd.OpenReport "Deposits", acNormal
Else: DoCmd.OpenReport "Deposits", acNormal, "", "[RegisterID] =
[Forms]![Deposit Slip]![RegisterID]"
End If
PrintCat = Null
DoCmd.Close acForm, Me.Name
 
Back
Top