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

Taking print out of recent record on the form 2

Status
Not open for further replies.

manf01

Technical User
Mar 20, 2005
26
DE


Hi programmers,

i have tried to use the provided code to get the print of the recent record on the form but i am just getting the copies of all records,

Can anyone suggest me how to get print of recent record.

I will be thankful to you


Dim stDocName As String
Dim strWhere As String

DoCmd.OpenReport stDocName, acPreview, strWhere
strWhere = "[InvoiceID]= & Me![InvoiceID]"
DoCmd.PrintOut "Invoice", acViewPreview

( Inovice is my Report name and InvoiceId is first field of the form )


Thanks a lot.
 
Code:
Dim stDocName As String
Dim strWhere As String
strWhere = "[InvoiceID]= & Me![InvoiceID]"
DoCmd.OpenReport stDocName, [b][COLOR=blue]acViewNormal[/color][/b], strWhere
I wonder why are you not getting an error on this line?!
Code:
[b][COLOR=red]DoCmd.PrintOut "Invoice", acViewPreview[/color][/b]


Zameer Abdulla
Visit Me (New Look & style)
 

Thanks a lot Zameer,

Its working properly

 

In taking a print out of recent record on the Form i have used a bit different way but i am getting an error in it.


DoCmd.OpenReport "InvoiceReport", asViewPreview
"[InvoiceID]=Forms!InvoiceForm!InvoiceID"

Anyone can correct me ?

Thanks a lot.
 
Hi
Has this line got a few typos?
DoCmd.OpenReport "InvoiceReport", [highlight]ac[/highlight]ViewPreview[highlight], , _[/highlight]
"[InvoiceID]=Forms!InvoiceForm!InvoiceID"
 
You can change the earlier code a little to open the report to preview not to print directly.
Code:
Dim stDocName As String
Dim strWhere As String
strWhere = "[InvoiceID]= & Forms!InvoiceForm!InvoiceID"
DoCmd.OpenReport stDocName, [b][COLOR=blue]acViewPreview[/color][/b], strWhere

Zameer Abdulla
Visit Me (New Look & style)
 

Thanks Remou

i have corrected it but still in vain
Can you please have a look on the code ?

Private Sub Print_Click()
On Error GoTo Err_Print_Click


DoCmd.OpenReport "InvoiceReport", acViewPreview, , _
"[InvoiceID]=Forms!InvoiceForm!InvoiceID"

Exit_Print_Click:
Exit Sub

Err_Print_Click:
MsgBox Err.Description
Resume Exit_Print_Click
End Sub


Thanks,

 


strDocName = "InvoiceReport"
DoCmd.OpenReport strDocName,acViewNormal, "Invoices Filter"

I have used the above function, now i am getting the required print out of recent record
 
Hi
In general you are best sticking fairly exactly to ZmrAbdulla's suggestions, so, copying Zameer's post:

Code:
Dim stDocName As String
Dim strWhere As String
strWhere = "[InvoiceID]= & Forms!InvoiceForm!InvoiceID"
strDocName= "InvoiceReport"
DoCmd.OpenReport stDocName, acViewPreview, strWhere

A few comments.
This line:
DoCmd.OpenReport stDocName, acViewPreview, strWhere
Opens with a filter.
This line:
DoCmd.OpenReport stDocName, acViewPreview, , strWhere
Opens with a where clause.

Are you 100% sure of the report name?
 
To highlight the post of Remou
This line:
Code:
DoCmd.OpenReport stDocName, acViewPreview[b][COLOR=red],[/color][/b] strWhere
Opens with a filter.
This line:
Code:
DoCmd.OpenReport stDocName, acViewPreview[b][COLOR=red], , [/color][/b]strWhere
Opens with a where clause.



Zameer Abdulla
Visit Me (New Look & style)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top