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!
Jackie L - 09 Apr 2008 20:58 GMT
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.
> 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
[quoted text clipped - 8 lines]
>
> Thanks for your help!
strive4peace - 09 Apr 2008 21:10 GMT
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 :)
*
> 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
[quoted text clipped - 8 lines]
>
> Thanks for your help!
Donna - 10 Apr 2008 18:36 GMT
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.
> 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
[quoted text clipped - 8 lines]
>
> Thanks for your help!
strive4peace - 10 Apr 2008 19:49 GMT
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
[quoted text clipped - 14 lines]
>>
>> Thanks for your help!