Print Selected Records

D

Donna

I have a continuous form that lists all students. I have a check box that
allows me to select the students I want (the check box is linked to a field
in the tblStudent table. There is a command button in the Form Header that
opens a report as follows:

Dim stDocName As String
stDocName = "rptApplForm"

DoCmd.OpenReport stDocName, acPreview, , "[SelectBox] = -1"

I have also tried:
DoCmd.OpenReport stDocName, acPreview, , me.SelectBox.value = -1

Either way, I can't get the report to print the selected students.

The first way, I get a popup asking for the parameter value of SelectBox.
If I leave it blank, I get 1 blank report; if I enter -1, I get ALL students'
reports.

The second way gives me all students reports also.
Does anyone have any idea what I am doing wrong?
 
D

Donna

Thanks for the reply. I checked and it is named SelectBox. So I decided to
delete the field in the table. I closed the database (compacting) opened it
and added a new Yes/No field titled "Print" in the table. I deleted the old
form & started from scratch with a new form. I still have the same problem,
other than it's prompting me for the parameters for PRINT now instead of
SELECTBOX. If I enter -1, it gives me all records, if I enter 0, it gives me
no records to print.

The code is:
Dim stDocName As String

stDocName = "rptApplForm"
DoCmd.OpenReport stDocName, acPreview, , "[Print] = -1"
Any other ideas?


Marshall Barton said:
Donna said:
I have a continuous form that lists all students. I have a check box that
allows me to select the students I want (the check box is linked to a field
in the tblStudent table. There is a command button in the Form Header that
opens a report as follows:

Dim stDocName As String
stDocName = "rptApplForm"

DoCmd.OpenReport stDocName, acPreview, , "[SelectBox] = -1"

I have also tried:
DoCmd.OpenReport stDocName, acPreview, , me.SelectBox.value = -1

Either way, I can't get the report to print the selected students.

The first way, I get a popup asking for the parameter value of SelectBox.
If I leave it blank, I get 1 blank report; if I enter -1, I get ALL students'
reports.

The second way gives me all students reports also.
Does anyone have any idea what I am doing wrong?

That implies that the name of the field in the table is not
named SelectBox. Perhaps it has a space or _ as the only
difference.
 
D

Donna

Nevermind; I figured it out. I needed to add the field to the query behind
the report also. Then it worked fine. Thanks for the help!

Marshall Barton said:
Donna said:
I have a continuous form that lists all students. I have a check box that
allows me to select the students I want (the check box is linked to a field
in the tblStudent table. There is a command button in the Form Header that
opens a report as follows:

Dim stDocName As String
stDocName = "rptApplForm"

DoCmd.OpenReport stDocName, acPreview, , "[SelectBox] = -1"

I have also tried:
DoCmd.OpenReport stDocName, acPreview, , me.SelectBox.value = -1

Either way, I can't get the report to print the selected students.

The first way, I get a popup asking for the parameter value of SelectBox.
If I leave it blank, I get 1 blank report; if I enter -1, I get ALL students'
reports.

The second way gives me all students reports also.
Does anyone have any idea what I am doing wrong?

That implies that the name of the field in the table is not
named SelectBox. Perhaps it has a space or _ as the only
difference.
 

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