Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 23rd, 2006, 10:43 PM
Registered User
 
Join Date: Mar 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Print subform problem

Hi all,

I have a form called Invoice which has a subform (Continuous form) embedded in it.

e.g.
frmInvoice
txtInvoiceNumber
txtCompanyName

sfrmOrderDetails
txtItemID
txtPrice
ExtPrice

=Sum([ExtPrice])which calculate the sum


I want to print a report of this form

=[Forms]("frmInvoice")![txtInvoiceNumber]
=[Forms]("frmInvoice")![txtCompanyName]

for the data on frmInvoice work fine

but when I tried
=[Forms]![frmInvoice]![sfrmOrderDetails]![txtItemID]
=[Forms]![frmInvoice]![sfrmOrderDetails]![txtPrice]
=[Forms]![frmInvoice]![sfrmOrderDetails]![ExtPrice]

showed #Name?

How could I print these continuous subform data on the report?

Thanks for your hlep.

J.K.W.Y.

 
Old April 24th, 2006, 08:40 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Create a report and print the report instead of the form.

HTH

mmcdonal
 
Old April 24th, 2006, 08:44 PM
Registered User
 
Join Date: Mar 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default


I tried to use the report wizard to create the report. But it shows all the invoices my database instead of the specific one that I want

 
Old April 25th, 2006, 06:20 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You need to pass a parameter to the report. I am not sure what you PK field is on the form. DO something like this:

Dim stDocName As String
Dim iPKID AS Integer 'if it is an autonumber field, for example
Dim sLink As String

iPKID = Me.PKID
sLink = "[PKID] = " & iPKID
stDocName = 'rptYourReportName"

DoCmd.OpenReport stDocName, acPreview, , sLink


You will have to confirm the syntax for the DoCmd line, but you want the link in the WHERE section. Place a button on your form called "Preview Report" and put this code on the On Click event.

Alternatively, if your report is based on a query, in the query design view, in the PK field criteria section put this criteria:

[Forms]![frmYourForm].[YourPKIDControlName]

Then on the form, create a button to open the report and don't modify the code. When the query runs, it will pull the PK ID from your form and only open the report with the contents of the current form/subform data.

HTH


mmcdonal
 
Old April 25th, 2006, 06:21 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Sorry, if you use this code, this line should be:

stDocName = "rptYourReportName"

not

stDocName = 'rptYourReportName"




mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
Textbox problem print preview vs. print jenisageek Access 5 May 2nd, 2008 12:54 PM
Subform problem fatrich Access VBA 6 October 4th, 2007 08:02 PM
Cant print when the form become subform yikchin Access 6 November 22nd, 2005 10:22 PM
form/subform problem chacquard Access VBA 5 June 21st, 2004 10:45 PM
Filtering Subform Problem sherr8 Access 4 May 19th, 2004 10:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.