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. - Private Sub cmdSavePDF_Click()
-
Dim strName As String
-
Dim strFilter As String
-
Dim strCurrentPath As String
-
Dim strReportFile As String
-
Dim strReport As String
-
strFilter = "[SSN] = '" & Me.MemberSelect & "'"
-
strName = Me.MemberSelect
-
strCurrentPath = Application.CurrentProject.Path
-
strReportFile = strCurrentPath & "\NewReport.pdf"
-
strReport = "rptECR"
-
-
Call DoCmd.OpenReport(ReportName:="rptECR", View:=Access.AcView.acViewReport, WhereCondition:=strFilter)
-
Debug.Print "Report and path: " & strReportFile
-
DoCmd.OutputTo objecttype:=acOutputReport, objectname:=strReport, outputformat:=acFormatPDF, outputfile:=strReportFile
-
DoCmd.Close acReport, "rptECR"
-
-
End Sub
Let me know if there is any other information that will help find a solution. Thx
Sgt B
Try the following as a replacement for line #10 (I'm assuming the table name is [tblECR] - change if necessary) : - strReportFile = DLookup(Expr:="[Long Name]", _
-
Domain:="[tblECR]", _
-
Criteria:=strFilter)
-
strReportFile = Replace(strCurrentPath & "\ECR%N.PDF", "%N", strReportFile)
5 2877
Hi again,
The answer is to include the identifier in strReportFile e.g. - strFilter = "[SSN] = '" & Me.MemberSelect & "'"
-
strName = Me.MemberSelect
-
strCurrentPath = Application.CurrentProject.Path
-
strReportFile = strCurrentPath & "\NewReport" & strName & ".pdf"
-
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
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) : - strReportFile = DLookup(Expr:="[Long Name]", _
-
Domain:="[tblECR]", _
-
Criteria:=strFilter)
-
strReportFile = Replace(strCurrentPath & "\ECR%N.PDF", "%N", strReportFile)
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
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().
I see thank you both very much.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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
|
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...
|
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
...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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,...
|
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...
| |