|
 |
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
|
 |
|
|
 |

November 19th, 2005, 06:03 AM
|
Authorized User
|
|
Join Date: Nov 2005
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

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
|
|
yikchin,
If txtReceiptID is on the subform, use it's full address:
Forms!frmTCMH!fSubLocalReceipt!txtReceiptID
or
Forms.frmTCMH.fSubLocalReceipt!txtReceiptID
HTH,
Loalee
|

November 19th, 2005, 11:35 PM
|
Authorized User
|
|
Join Date: Nov 2005
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i've tried but it print empty report .
|

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
|
|
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
|

November 20th, 2005, 11:19 PM
|
Authorized User
|
|
Join Date: Nov 2005
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
It only print out the label but no data. i place the command in the subform and txtReceiptID is also in the subform.
|

November 21st, 2005, 11:52 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
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
|

November 22nd, 2005, 10:22 PM
|
Authorized User
|
|
Join Date: Nov 2005
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank you for your help.
|
Thread Tools |
Search this Thread |
|
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |