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

Print Report from a Subform (Tab form) in a Main Form

Status
Not open for further replies.

PrimoSteve

Technical User
Aug 11, 2021
25
0
1
IE
Hi,

I have a Main form "ManuF" and a subform which is a Tab form "Jobs".
I have no problem printing this report "repFileCover" from the Jobs form when this form is opened by itself

OnClick event: DoCmd.openReport "repFileCover", acViewPreview
Query behind the "repFileCover" below


SELECT Jobs.JobID, Companies.Name, Jobs.Collect, [Delivery Dockets].CollectionDate, Consignors.Name, [Delivery Dockets].PurchaseOrderNo, [Delivery Dockets].Packages, [Delivery Dockets].GoodsDescription, [Delivery Dockets].Weight, [Delivery Dockets].ColInstructions, Consignors.Address1, Jobs.JobID & " / " & [DeliveryDocketNo] AS Ref, Consignors_1.Name AS Consignee, Companies.Message, Customers.Name, [Delivery Dockets].SpecNo, Consignors_1.Address1, Jobs.JobDate, Jobs.EnteredBy, Jobs.Vessel, Jobs.CameFrom, Jobs.CustomerRef
FROM (Companies INNER JOIN Jobs ON Companies.CompanyID = Jobs.JobTypeID) INNER JOIN (Consignors INNER JOIN (Customers INNER JOIN (Consignors AS Consignors_1 INNER JOIN [Delivery Dockets] ON Consignors_1.ConsignorID = [Delivery Dockets].ConsigneeID) ON Customers.CustomerID = [Delivery Dockets].CustomerID) ON Consignors.ConsignorID = [Delivery Dockets].ConsignorID) ON Jobs.JobID = [Delivery Dockets].JobID
WHERE (((Jobs.JobID)=[Forms]![Jobs]![JobID]));

But when the form "Jobs" is a Subform of the Main form "Menuf" I have a problem printing this report.
I have tried using =[Forms]![Menuf]![Jobs].[Form]![JobID] as the criteria on the above query but to no success.

The report does print after the this messagebox appears and the OK button is clicked

Enter Parameter Value ?
Forms!Jobs!JobID

Ok Cancel

Any assistance would be greatly appreciated

 
I rarely use a criteria like this in a report preferring to apply the WHERE CONDITION in the DoCmd.OpenReport. The code to open the report would be something like:

If JobID is numeric:
D
Code:
oCmd.openReport "repFileCover", acViewPreview, , "JobsID = " Me.JobID

If JobID is a string:
Code:
DoCmd.openReport "repFileCover", acViewPreview, , "JobsID = """ Me.JobID & """"

This uncouples the report from having to depend on a form.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top