473,386 Members | 1,883 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,386 software developers and data experts.

Save to PDF File Name AutoCreate

Brilstern
208 100+
Q: How do I relate the desired filename to a field within the table of the datasource to "autoname" the file when saved.

In the below code the filename is NewReport. I want to change this to be the [Long Name] field of each record source when it saves. Reason being in the "autoname" function is because eventually I am going to create an archive button that will save a copy for each record to a monthly folder.


Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSavePDF_Click()
  2. Dim strName As String
  3. Dim strFilter As String
  4. Dim strCurrentPath As String
  5. Dim strReportFile As String
  6. Dim strReport As String
  7. strFilter = "[SSN] = '" & Me.MemberSelect & "'"
  8. strName = Me.MemberSelect
  9. strCurrentPath = Application.CurrentProject.Path
  10. strReportFile = strCurrentPath & "\NewReport.pdf"
  11. strReport = "rptECR"
  12.  
  13.    Call DoCmd.OpenReport(ReportName:="rptECR", View:=Access.AcView.acViewReport, WhereCondition:=strFilter)
  14.    Debug.Print "Report and path: " & strReportFile
  15.    DoCmd.OutputTo objecttype:=acOutputReport, objectname:=strReport, outputformat:=acFormatPDF, outputfile:=strReportFile
  16.    DoCmd.Close acReport, "rptECR"
  17.  
  18. End Sub
Let me know if there is any other information that will help find a solution. Thx

Sgt B
Jan 30 '12 #1

✓ answered by NeoPa

Try the following as a replacement for line #10 (I'm assuming the table name is [tblECR] - change if necessary) :
Expand|Select|Wrap|Line Numbers
  1. strReportFile = DLookup(Expr:="[Long Name]", _
  2.                         Domain:="[tblECR]", _
  3.                         Criteria:=strFilter)
  4. strReportFile = Replace(strCurrentPath & "\ECR%N.PDF", "%N", strReportFile)

5 2877
sierra7
446 Expert 256MB
Hi again,
The answer is to include the identifier in strReportFile e.g.
Expand|Select|Wrap|Line Numbers
  1. strFilter = "[SSN] = '" & Me.MemberSelect & "'" 
  2. strName = Me.MemberSelect 
  3. strCurrentPath = Application.CurrentProject.Path 
  4. strReportFile = strCurrentPath & "\NewReport" & strName & ".pdf" 
  5.  
However, refereing back to your other question about looping through BandMembers, then this is a good example why you might want to use looping rather than have a continuous report (with page breaks) Each member would have a seperate report that could be emailed to him personally. The continuous report being more of a Control Document for management purposes.
S7
Jan 30 '12 #2
NeoPa
32,556 Expert Mod 16PB
Try the following as a replacement for line #10 (I'm assuming the table name is [tblECR] - change if necessary) :
Expand|Select|Wrap|Line Numbers
  1. strReportFile = DLookup(Expr:="[Long Name]", _
  2.                         Domain:="[tblECR]", _
  3.                         Criteria:=strFilter)
  4. strReportFile = Replace(strCurrentPath & "\ECR%N.PDF", "%N", strReportFile)
Jan 30 '12 #3
Brilstern
208 100+
NeoPa,

That did the trick, I have never used the Dlookup function, new one to put into the toolbox. Thx

Sierra7,

Thx for the input, led exactly to NeoPa's example:)

Sgt B
Jan 30 '12 #4
NeoPa
32,556 Expert Mod 16PB
It's also possible to use recordset code to access the same data, but generally a single access (to get one bit of data) can better be handled by the Domain Aggregate functions, of which one such is DLookup().
Jan 30 '12 #5
Brilstern
208 100+
I see thank you both very much.
Jan 30 '12 #6

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

Similar topics

1
by: dead | last post by:
Hi, Is it possible to set the output file name of a excel file from javascript? I have a code which copies the content of an html page and pastes it into excel. I want the user to save the...
2
by: rmunson8 | last post by:
What is the appropriate control or code to pop a "save as" dialog window to allow the user of a web page to save a document after they click on a link? All of the CommonDialog controls obviously...
3
by: AJ | last post by:
Hi , I am trying to dynamically change file name of an html that is generated through a cgi script, I know that for it is easy to do this for other type of files such as pdf or csv which we...
9
by: Ivan Demkovitch | last post by:
Hi! I would like to know if I can save File on Server using server-side code? For example, I like to create thumbnail images and populate specific directory. Do I need specific permissions...
0
by: Tuan Nguyen | last post by:
Hi all, I am writing asp.net with access database. I want to store text (messages) in the access database. However, the text data type in access database only allows me to store up to 255...
10
by: GJP | last post by:
Hello. Ive been asked to make my own notepade for college assignment. All ig going well, but i cant get the save to work. I can get Save a (shows dialog box), i can get it to just save too,...
4
by: Jonny | last post by:
Hello Group How do I open a Save File Dialog from an ASPX page behind a browse button? Any help would be fantastic!! I am using ASP.NET 1.1 using VB.NET as the coding language TIA
3
by: vellyna | last post by:
how to appear path file name? for example, i have select "books" from list, then i browse the file.. after browse the file, i want to appear the path file name that will save the file in a...
3
by: aGSMITH | last post by:
Hello All, I have an exportfile .txt from robocopy utility and I would need to get file name path from the file and save it to file1.txt after get the filename value and save it to file2.txt ...
185
by: jacob navia | last post by:
Hi We are rewriting the libc for the 64 bit version of lcc-win and we have added a new field in the FILE structure: char *FileName; fopen() will save the file name and an accessor function will...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.