473,394 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

I need a VBA code to print the report

Hi,
I have a report named PIRREPORTFORMD17792. Every time I try to print out a record, the MS Access 2010 uses PIRREPORTFORMD17792 as a default file name.
Instead of using PIRREPORTFORMD17792 as a default file name for all the reports, I would like to use a field on the form for the file name. This field called PIRNO. (This field will automatically generate a number such as PIR20014-0001, PIR2014-0002 and ect. whenever a new record is added.)
Here is an example of what I want:
If I am currently on a record shown PIR20014-0001, then I want the file name of this report (in PDF) to be converted to PIR20014-0001 instead of PIRREPORTFORMD17792. I would appreciate your help a lot.

Regards,

Paul
Attached Images
File Type: jpg image.jpg (61.5 KB, 364 views)
Apr 29 '14 #1
3 2961
Seth Schrock
2,965 Expert 2GB
I use the DoCmd.OutputTo method to export my reports as PDFs. This allows you to specify the report name in the OutputFile argument. Here is a link to the MSDN website explaining the command: MSDN: DoCmd.OutputTo
Apr 29 '14 #2
Hi Seth,
I am new at VBA code.
Below is the VBA code which I use to print. If you can, could you please show me how to change it? Thank you.


Expand|Select|Wrap|Line Numbers
  1. Private Sub Command265_Click()
  2. Dim strWhere As String
  3.  
  4.     If Me.Dirty Then    'Save any edits.
  5.         Me.Dirty = False
  6.     End If
  7.  
  8.     If Me.NewRecord Then 'Check there is a record to print
  9.         MsgBox "Select a record to print"
  10.     Else
  11.         strWhere = "[PIRNO] = " & Me.[PIRNO]
  12.         DoCmd.OpenReport "PIRREPORTFORMD17792", acViewPreview, , strWhere
  13.     End If
  14. End Sub
Apr 29 '14 #3
zmbd
5,501 Expert Mod 4TB
Please follow the link that Seth gave you and read how to use the command.
Then attempt to alter your code to use the option given to you by Seth.
If you are still not obtaining the desired results then post back.
Normally, we're not here to write the code for you - that is somehthing you really must do for yourself or you will never benefit from the knowledge.

-z
Apr 30 '14 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Michael Dekson | last post by:
Access 97. I make a report and I want first to see report and then print report without type CONTROL + P. Can I make some button or can I see print button in toolbar meny. Thanks
0
by: Sharknwfk | last post by:
Hi, Access 2003. Hoping someone can help. We need to print a report/sub report onto a continuous(Two Page, A4) Form. Is this possible? Any help appreciated.
5
by: Jay | last post by:
In an ASP.NET page I have a fairly lengthy datagrid that I need to print. Problem is that when I print sometimes the last row on that page gets cut half way through. Is there a way to print a...
5
by: Tony Dong | last post by:
Hi there, I am newer for dot net I want to make a report and then print it, the report may include images and text, how can I do that, any one can give me a suggestion? I know how to...
1
by: ljungers | last post by:
Morning to all. I have been working on a selection process that will use filtered/query data to print a report. With the great help provided here on this fourm, I am down to the last step. What...
1
by: stalinkakinada | last post by:
I want to take printouts of 20000 records cards in which I need to print boths side. I prepared 2 forms(same table field are in 2 forms) each page gets 8 records . I printed one side , but when I...
2
by: felicia | last post by:
Can anyone help me on How to use Data Report in VB and how to print report? I hope i can generate the Data Report without Data Environment because I am not fammiliar with it. Simple adodb or adodc...
2
by: voroojak | last post by:
Hi i need to print my report in PDF format but i dont know how? i would appreciate any help. thanks
0
by: Srinidhi | last post by:
I need to print multiple labels (like business card) on a Letter size sheet. I'm using list control (winforms report viewer) with a very few vertically placed TextBoxes in it. The List repeats...
1
by: abil | last post by:
i've already build a program that contain all the price, the change given back to the customer but i dun have no idea which function i should use to do program print report... #include <cstdlib>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.