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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Preview, print reports from a form (Rookie) 1

Status
Not open for further replies.

kurtley

Technical User
Jan 25, 2002
1
US
I have a form that uses a sub form to link data from 2 databases ( a parent and child). I have created a report with a sub report that prints the same info, except the report prints all of the records from the parent database with the associated child records on the subform. I want the report to print from a single selected value on my form. It is the primary key on my viewing form (which is in a combo box) that links the child data. I would like the form to let me create and preview the report for the selected parent record shown on the form. The report would be for the single selected record from the parent database with the associated child data, instead of all of the parent records/w child records. I need help on how I set up a control button to do this. I am using ACCESS 97. Any help would be greatly appreciated.

Thanks,
Kurtley
 
Here is a example of how I set this up on a print button that will print only the student who information is showing on the form.

Private Sub cmdReport_Click()
On Error GoTo Err_cmdReport_Click

Dim stDocName As String

stDocName = "rptSchoolNurseReport"
DoCmd.OpenReport "rptSchoolNurseReport", acViewNormal, , "[StudID]=" & [StudID]
//This will limit the report to only the student ID that appears on the form

Exit_cmdReport_Click:
Exit Sub

Err_cmdReport_Click:
MsgBox Err.Description
Resume Exit_cmdReport_Click

End Sub

I hope this will lead you in the right direction.

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top