Select Records to Print

D

Donna

I have created a form that allows me the ability to select what employees I
want to print a contract (report) for. It works great except for it always
leaves the 1st person off. For example, if I put a check in the 3rd & 4th
person's names on the form, only the 4th person's contract prints. If I put
a check in the 1st, 2nd, 3rd, 4th, 5th, 6th person's name on the form, all
print except for the 1st person.

My code in the onclick event of the command button to print the report is:
DoCmd.OpenReport stDocName, acPreview, , "[Print] = -1"
where [Print] is the name of the checkbox

Thanks for your help!
 
J

Jackie L

Since we do not see the entire code, do you have as the first line
Me.Refresh

You can always base your report off a query which has the criteria of True
for your check box.

Either way, you should have Me.Refresh first or you lose the last field
change.
 
S

strive4peace

Hi Donna,

do not use PRINT as a fieldname or controlname (etc), it is a reserved word

Problem names and reserved words in Access, by Allen Browne
http://www.allenbrowne.com/AppIssueBadWord.html

~~~

my guess is that whatever record you are on is not being saved before
the report is rendered. In the code behind your form, do this:

if me.dirty then me.dirty = false

if.me dirty --> returns TRUE if the record needs to be saved
me.dirty = false --> saves the record

.... then issue the command to do the report <smile>

~~~
whatever criteria you use must be fields ON the report in a control --
the Visible property can be no

Warm Regards,
Crystal

*
:) have an awesome day :)
*
 
D

Donna

I changed the field name from Print to PrintRpt. Then I figured out that it
wasn't printing whatever the last record was that I was selecting on the
form. So as long as I click anywhere on the form after I've made my last
selection, all records checked get printed. I'm sure it's not supposed to
work that way, but it does solve the problem for now.
 
S

strive4peace

Hi Donna,

"I changed the field name from Print to PrintRpt."

good!

"So as long as I click anywhere on the form after I've made my last
selection, all records checked get printed. "

that is not necessary if you include this code:

if me.dirty then me.dirty = false

'me' refers to the form you are behind
'dirty' is the property that indicates True or False if unsaved changes
have been made to a record

this statement will save the record you have just modified -- and do
nothing if no changes have been made

Warm Regards,
Crystal

*
:) have an awesome day :)
*

I changed the field name from Print to PrintRpt. Then I figured out that it
wasn't printing whatever the last record was that I was selecting on the
form. So as long as I click anywhere on the form after I've made my last
selection, all records checked get printed. I'm sure it's not supposed to
work that way, but it does solve the problem for now.

Donna said:
I have created a form that allows me the ability to select what employees I
want to print a contract (report) for. It works great except for it always
leaves the 1st person off. For example, if I put a check in the 3rd & 4th
person's names on the form, only the 4th person's contract prints. If I put
a check in the 1st, 2nd, 3rd, 4th, 5th, 6th person's name on the form, all
print except for the 1st person.

My code in the onclick event of the command button to print the report is:
DoCmd.OpenReport stDocName, acPreview, , "[Print] = -1"
where [Print] is the name of the checkbox

Thanks for your help!
 

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