Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

subreports not printing

Status
Not open for further replies.

kc112

Technical User
May 16, 2011
41
US
ok...I'm at a loss with this one.

I have my report with multiple subreports.

I can print the report and all subreports show up.

I have a mainframe form that gives the user an option to select one patient record and print the report. This prints all subreports.

BUT!! I also added a print button directly on the form (the form that enters the data) to print the current patient record report. THIS print command only prints the main report and 2 of the 5 subreports?? It does not matter which subreport, its whichever one I load onto the report first in design view.

I played with visible properties, can grow/shrink properties, etc... but to no avail. The really wierd part is that the report itself is fine, its when I try to print the report from the form that it does not wholly populate.

Please help!!!

Thank you

 
Please show us the code.

Gluais faicilleach le cupan làn
 
This is the code from the mainframe that allows users to select one record and print. This prints all subreports correctly:

Private Sub Command5_Click()
On Error GoTo Err_Command5_Click

Dim stDocName As String
Dim strwherecategory As String

strwherecategory = "[key] = forms![printtxplan]!records"

stDocName = "Treatment Plan Data Report"

DoCmd.OpenReport stDocName, acViewPreview, , strwherecategory

Exit_Command5_Click:
Exit Sub

Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click

End Sub


This is the code via the button on my form to print the current record. This DOES NOT print all subforms:

Private Sub print_treatment_plan_report_Click()
On Error GoTo Err_print_treatment_plan_report_Click

Dim stDocName As String
Dim strwherecategory As String

strwherecategory = "[key] = " & Me.[Key]

stDocName = "Treatment Plan Data Report"

DoCmd.OpenReport stDocName, acViewPreview, , strwherecategory

Exit_print_treatment_plan_report_Click:
Exit Sub

Err_print_treatment_plan_report_Click:
MsgBox Err.Description
Resume Exit_print_treatment_plan_report_Click
End Sub
 
Code:
strwherecategory = "[key] = " & Me.[Key]

A couple things:
Even though enclosed in brackets, "Key" is a reserved word in Access and it's use as a field name should be avoided.

On the main report, are the subreports LinkChild / Master properties set to the Key field?

Gluais faicilleach le cupan làn
 
Unfortunately, this is my first access program and I did not learn the 'key' faux pas until after I already created it.

key is the primary key on the main form 'tx plan data'

for subsequent forms, I wised up!

cervical exam
primary key - pkcerv
foriegn key - keytx

hand exam
primary key - pkhand
foriegn key - keycerv

lumbar exam
primary key - pklum
foriegn key - keytx

foot exam
primary key - pkfoot
foriegn key - keylum

and so forth on the rest of my forms. I am afraid to go back and change the primary key field [key] on my main form becuase of the errors it might cause me :(((

Yes, I checked all of the parent/child relationships and they are correctly linked. As I stated, the entire report and all subreports correctly prints from the other form and if I click directly on the report.

Its only on the tx plan data form that it skips subreports. And ironically, it can skip any of them. I tried to re-do the entire report, and put each subreport on by itself and tried the print command button from the tx plan data form, and each subreport showed up. The moment I add the multiple subreports, they begin to go missing.

I thought that it maybe had something to do with 'duplicates'? since, they all have the same 'keytx' as a foriegn key? but not sure where on my form i can check on that.
 
I suspect Me.[Key] in your form code is to blame. What are you trying to reference? Is your form bound to a table and you are trying to reference a field on the current record?

Gluais faicilleach le cupan làn
 
Yes, the form is from the 'treatment plan data' table. [key] is a field titled = key, that is my primary key for that table.

here are my tables (abridged version):

maintbl - txplandata
primary key - key
pt first name
pt last name
pt id
tx plan date

subtbl - complaint
primary key - pkhpi
foriegn key - keytx
location
severity
quality

subtbl - diagnosis
primary key - pkdx
foreign key - keyhpi
diagnosis primary
diagnosis secondary

subtbl - cervicalexam
primary key - pkcerv
foriegn key - keytx
curve
head tilt
date

subtbl - hand exam
primary key - pkhand
foriegn key - keycerv
froments sign

subtbl - lumbarexam
primary key - pklum
foriegn key - keytx
pelvic turn
leaning
date

subtble - foot exam
primary key - pkfoot
foriegn key - keylum
tinels sign


This is so confusing to try and type! But here are the relationships. I have 3 tiers:

Main table - txplandata
sub table - complaint
subtbl - diagnosis
sub table - cervical exam
subtbl - hand exam
sub table - lumbar exam
subtbl - foot exam

Again, all of my relationships and pk/fk are populated correctly because the report itself prints fine and correct. It is just from the main table form print command button that it fails to print. (it even prints correctly from my main switchboard form)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top