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

Call subform from a Popup form

Status
Not open for further replies.

techi1961

Technical User
Aug 6, 2014
10
IE
Hi,

How do you call/refer to a subform (Delivery Dockets) of a form (Jobs) from a popup form (Print Screen). I have a form called Jobs and subform called Delivery Dockets.
I have cmdButton on the main form that runs the code below to open a popup form called "Print Screen" for printing reports. Currently users enter a number of reports to print in a field called "Pieces" of the subform.

Dim I As Integer

If Me.Flagged = True Then
DoCmd.SetWarnings False

DoCmd.OpenQuery "DeleteDeliveryTemp", acNormal, acEdit
DoCmd.OpenQuery "AppendDeliveryTemp", acNormal, acEdit

For I = 1 To Forms!Jobs![Delivery Dockets].Form!Pieces

Next

DoCmd.SetWarnings True
stDocName = "Print Screen"
DoCmd.OpenForm stDocName

I would like users to enter the number to print in an unbound field called "NumberToPrint" in the popup form "Print Screen" but can't get my around how to refer to a subform on a form from a popup form.

Thanks
 
What happens when you run your code? Do you get an error message or a prompt?
Do you understand the difference between the name of the subform control and the name of the source object? You need to use the subform control name in your expressions.

What have you done to trouble-shoot? What do you see in the debug window if you add this line to your code?

Code:
debug.Print Forms!Jobs![Delivery Dockets].Form!Pieces

Duane
Hook'D on Access
MS Access MVP
 
Hi Duane,
Sorry, the code works fine. It is called from the main form that calls the popup print form which the user just clicks a control to print the report (record source the Delivery Docket Temp Table)
Your right the name of the source object is the Delivery Docket Temp Table which is appended from the Delivery Dockets Table, recordsource of the subform.

SELECT [Delivery Docket Temp].Delivery, [Delivery Docket Temp].DeliveryDocketID, [Delivery Docket Temp].JobID,[Delivery Docket Temp].BatchNo, [Delivery Docket Temp].Pieces, [Delivery Docket Temp].GoodsDescription, [Delivery Docket Temp].Weight, [Delivery Docket Temp].DANNumber, [Delivery Docket Temp].P, Right("0000" & [JobID],4) & Right("0000" & [DeliveryDocketID],5) AS Barcode, [Delivery Docket Temp].Delivery AS DD AS PP
FROM [Delivery Docket Temp] INNER JOIN Consignors ON [Delivery Docket Temp].ConsignorID = Consignors.ConsignorID
WHERE ((([Delivery Docket Temp].JobID)=[Forms]![Jobs]![JobID]));

Currently users enter a number of reports to print in a field which is [Delivery Docket Temp].P on the above query. What I would like is the users to enter the number to print in an unbound field called "NumberToPrint" in the popup form "Print Screen" instead of entering this on the subform.

Hope I made this clear...Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top