Open Report with only selected records to print?

D

Dave Elliott

Below is my code to open the report and print the current record.
This code is generated via a command button on a form.
Also on the form is a Yes/No check box that if it is checked (Yes)
(Selected) is the control name
Then I want it to print the records that are selected to print.
The control is named (Selected) on the form.
On the form also is a way to Batch print.
How can I modify this code to achieve the desired result?

DoCmd.OpenReport "RCheckAll", acNormal, "",
"[ChkNoID]=[Forms]![FEmpTotHours]![ChkNoID]"
 
J

John Vinson

Below is my code to open the report and print the current record.
This code is generated via a command button on a form.
Also on the form is a Yes/No check box that if it is checked (Yes)
(Selected) is the control name
Then I want it to print the records that are selected to print.
The control is named (Selected) on the form.
On the form also is a way to Batch print.
How can I modify this code to achieve the desired result?

DoCmd.OpenReport "RCheckAll", acNormal, "",
"[ChkNoID]=[Forms]![FEmpTotHours]![ChkNoID]"

Unless the form control [Selected] is bound to a table field, it won't
help you here. The report is not printing the data from the form; it's
printing data FROM THE TABLE, and the form is also displaying the data
from the table.

If the table contains a yes/no field named Selected just add it to the
WhereCondition argument:

DoCmd.OpenReport "RCheckAll", acNormal, "",
"[ChkNoID]=[Forms]![FEmpTotHours]![ChkNoID] AND [Selected] = True"


John W. Vinson[MVP]
 
D

Dave Elliott

THANKS, that did the trick...

John Vinson said:
Below is my code to open the report and print the current record.
This code is generated via a command button on a form.
Also on the form is a Yes/No check box that if it is checked (Yes)
(Selected) is the control name
Then I want it to print the records that are selected to print.
The control is named (Selected) on the form.
On the form also is a way to Batch print.
How can I modify this code to achieve the desired result?

DoCmd.OpenReport "RCheckAll", acNormal, "",
"[ChkNoID]=[Forms]![FEmpTotHours]![ChkNoID]"

Unless the form control [Selected] is bound to a table field, it won't
help you here. The report is not printing the data from the form; it's
printing data FROM THE TABLE, and the form is also displaying the data
from the table.

If the table contains a yes/no field named Selected just add it to the
WhereCondition argument:

DoCmd.OpenReport "RCheckAll", acNormal, "",
"[ChkNoID]=[Forms]![FEmpTotHours]![ChkNoID] AND [Selected] = True"


John W. Vinson[MVP]
 
D

Dave Elliott

The Third line of code below only prints the current selected record, not
all selected records??? (Selected =True)
What do I need to change?


DoCmd.OpenReport "RCheckAll", acNormal, "",
"[ChkNoID]=[Forms]![FEmpTotHours]![ChkNoID]" (Print One)
DoCmd.OpenReport stDocName, acNormal (Print All)
DoCmd.OpenReport stDocName, acNormal, "",
"[ChkNoID]=[Forms]![FEmpTotHours]![ChkNoID] AND [Selected] = True" (Print
All Selected)





John Vinson said:
Below is my code to open the report and print the current record.
This code is generated via a command button on a form.
Also on the form is a Yes/No check box that if it is checked (Yes)
(Selected) is the control name
Then I want it to print the records that are selected to print.
The control is named (Selected) on the form.
On the form also is a way to Batch print.
How can I modify this code to achieve the desired result?

DoCmd.OpenReport "RCheckAll", acNormal, "",
"[ChkNoID]=[Forms]![FEmpTotHours]![ChkNoID]"

Unless the form control [Selected] is bound to a table field, it won't
help you here. The report is not printing the data from the form; it's
printing data FROM THE TABLE, and the form is also displaying the data
from the table.

If the table contains a yes/no field named Selected just add it to the
WhereCondition argument:

DoCmd.OpenReport "RCheckAll", acNormal, "",
"[ChkNoID]=[Forms]![FEmpTotHours]![ChkNoID] AND [Selected] = True"


John W. Vinson[MVP]
 
J

John Vinson

The Third line of code below only prints the current selected record, not
all selected records??? (Selected =True)
What do I need to change?


DoCmd.OpenReport "RCheckAll", acNormal, "",
"[ChkNoID]=[Forms]![FEmpTotHours]![ChkNoID]" (Print One)
DoCmd.OpenReport stDocName, acNormal (Print All)
DoCmd.OpenReport stDocName, acNormal, "",
"[ChkNoID]=[Forms]![FEmpTotHours]![ChkNoID] AND [Selected] = True" (Print
All Selected)


Leave off

[ChkNoID]=[Forms]![FEmpTotHours]![ChkNoID] AND

if the only criterion you want to apply is [SELECTED] = True.

The argument is basically just a SQL Query WHERE clause without the
word WHERE. Apply whatever criteria you want, and leave off any
criteria you don't want.

John W. Vinson[MVP]
 
D

Dave Elliott

Thanks, works great...Really appreciate your time in this newsgroup!
Dave

John Vinson said:
The Third line of code below only prints the current selected record, not
all selected records??? (Selected =True)
What do I need to change?


DoCmd.OpenReport "RCheckAll", acNormal, "",
"[ChkNoID]=[Forms]![FEmpTotHours]![ChkNoID]" (Print One)
DoCmd.OpenReport stDocName, acNormal (Print All)
DoCmd.OpenReport stDocName, acNormal, "",
"[ChkNoID]=[Forms]![FEmpTotHours]![ChkNoID] AND [Selected] = True" (Print
All Selected)


Leave off

[ChkNoID]=[Forms]![FEmpTotHours]![ChkNoID] AND

if the only criterion you want to apply is [SELECTED] = True.

The argument is basically just a SQL Query WHERE clause without the
word WHERE. Apply whatever criteria you want, and leave off any
criteria you don't want.

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top