Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
| Search | Today's Posts | Mark Forums Read
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 November 19th, 2005, 06:03 AM
Authorized User
 
Join Date: Nov 2005
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Cant print when the form become subform

I create a form called "fSubLocalReceipt", everything is alright when i'm testing, like print the particular report

However, when i embed it into a form call "frmTCMH", and click the print report button. The message box pop up to prompt me enter the parameter value. How to solve this proble? the code for printing the particular record is:

Private Sub cmdPrintCert_Click()
On Error GoTo Err_cmdPrintCert_Click

    Dim strDocName As String
    Dim strFilter As String

    strDocName = "rptPrintLocalCert"
    strFilter = "txtReceiptID=Forms!fSubLocalReceipt!txtReceip tID"
    DoCmd.OpenReport strDocName, acNormal, , strFilter

Exit_cmdPrintCert_Click:
    Exit Sub

Err_cmdPrintCert_Click:
    MsgBox Err.Description
    Resume Exit_cmdPrintCert_Click

End Sub

 
Old November 19th, 2005, 03:35 PM
Friend of Wrox
 
Join Date: Mar 2004
Location: Yorba Linda, California, USA.
Posts: 217
Thanks: 0
Thanked 1 Time in 1 Post
Default

yikchin,
If txtReceiptID is on the subform, use it's full address:

Forms!frmTCMH!fSubLocalReceipt!txtReceiptID

or

Forms.frmTCMH.fSubLocalReceipt!txtReceiptID

HTH,
Loalee

 
Old November 19th, 2005, 11:35 PM
Authorized User
 
Join Date: Nov 2005
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i've tried but it print empty report .

 
Old November 20th, 2005, 01:16 PM
Friend of Wrox
 
Join Date: Mar 2004
Location: Yorba Linda, California, USA.
Posts: 217
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yikchin,
So the report is printing but there is no data? Or is the paper coming off the printer totally blank?

You might check that the controls are within the printing area (and within the margins). I've had reports that seemed blank until I moved the controls furhter within the margins. (Go to Page Set up on your menu). I assume the field txtReceiptID is on both the report and the subform you are launching from....

BTW:In OpenReport you have strFilter in the position the WHERE clause argument belongs, but that really SHOULDN'T matter here because what you put IN strFilter is a WHERE clause.

The syntax is:
DoCmd.OpenReport stDocName, acViewPreview, Filter, WHERE clause.

IE:
Dim strDocName As String
    Dim strWHERE As String

    strDocName = "rptPrintLocalCert"
    strWHERE = "txtReceiptID=Forms!fSubLocalReceipt!txtReceip tID"
    DoCmd.OpenReport strDocName, acNormal, , strWHERE


HTH,
Loralee


 
Old November 20th, 2005, 11:19 PM
Authorized User
 
Join Date: Nov 2005
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It only print out the label but no data. i place the command in the subform and txtReceiptID is also in the subform.


 
Old November 21st, 2005, 11:52 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

You're mixing up the name of a field in a table vs. the name of a control on the form; and you're also not putting the second half of the filter outside the quotes if you're comparing to a form control.

strWHERE = "txtReceiptID=Forms!fSubLocalReceipt!txtReceip tID"

should be (assuming your button is on the main form)

strWHERE = "[XXX] = " & Me.fSubLocalReceipt.Form.txtReceiptID

Where you must replace XXX with the name of the field in the table that the textbox txtReceiptID is bound to. So for example, if the textbox txtReceiptID is bound to the field called lngReceiptID in your table, then

strWHERE = "[lngReceiptID] = " & Me.fSubLocalReceipt.Form.txtReceiptID

The "Me." is a shortcut for "Forms.frmTCMH."


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old November 22nd, 2005, 10:22 PM
Authorized User
 
Join Date: Nov 2005
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your help.







Similar Threads
Thread Thread Starter Forum Replies Last Post
How centre a form for printin using Print Form VBProg VB.NET 2002/2003 Basics 0 October 23rd, 2006 03:12 PM
Open a subform from a form Vision G Access 5 May 13th, 2006 04:21 AM
Print subform problem J.K.W.Y. Access 4 April 25th, 2006 06:21 AM
How to link form and subform method Access 1 July 30th, 2005 02:19 AM
form/subform problem chacquard Access VBA 5 June 21st, 2004 10:45 PM





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