Hi Evereyone,
I’m looking for some help and I’m sure to find it here ;o)
I’ve created in access a simple database to obtain reports. Via a combobox I select a customer number, click on a button and the specific report appears.
I’m able to save manually each report to a pdf file and give it a name, but I want it to be
automatically done. The most important is that filename must be “customer name” and “code” appearing on the report.
I’ve found some solutions but not working in practice.
My DB is composed of:
- A query named “QryHyperion” based on 2 excell files
o Fields composing the DB: - Hyperion
- Name
- SAP
- Some others(not important to be mentioned)
- A report named “ RptHyperion”
- A form named “form1” with a combobox named “combo8”
Actual used syntax: - Dim myPath As String
-
Dim strReportName As String
-
-
DoCmd.OpenReport "RptHyperion", acViewPreview, , "[SAP]=" & Me![Combo8], acWindowNormal
-
-
myPath = "S:\Accounts\Reconciliations\Recon letters\"
- strReportName = [Name] + "-" + [Hypérion] + ".pdf" (this line causes me trouble)
-
DoCmd.OutputTo acOutputReport, "", acFormatPDF, myPath + strReportName, True
-
DoCmd.Close acReport, "RptHyperion"
File must be saved as “Name” & “Hyperion” .pdf
So how do I have to link both fields to be used as filename when saving?
Thanks in advance for helping me
Ok, so this is what I would do:
Change the rowsource of the combobox to: - SELECT SAP,Cust,Hyperion
-
FROM [Hyperion accounts]
-
ORDER BY [SAP];
Now the code can get easy access to the information Hyperion and Cust from the combobox like so: - strReportName = Me.cmb_SelectSap.Column(1) & "-" & Me.cmb_SelectSap.Column(2) & ".pdf"
(Just for clarity, column(0) is the SAP number)
11 19897
At at first glance, im guessing that the place where you run the code might not have access to the fields [Name] and [Hypérion].
Are you running the code from a form module, or a seperate module?
And if from a form, does the forms recordsource include [Name] and [Hyperion]?
If they do, try this.
First, Name is reserved word in access, and using that as a field name will likely cause you grief, and in alot of cases probably grief in a non-sensical way. For example to refer to Form.Name is that the field name in the forms underlying recordset, or the forms name?
If you insist on keeping the field named Name, then have a control on the form bound to the field, but make sure the control is named something else, for example tb_Name (TextBox name). Then you could use: - strReportName = Me.tb_Name & "-" & Me.tb_Hypérion + ".pdf"
Hope this helps you.
Are you receiving an error message? If so, can you provide it? Are you sure you have permissions to the folder where you're trying to export the file?
Have you tried removing the myPath + strReportName argument in the DoCmd.OutputTo altogether to see if Access prompts you to name the file?
Also, you may want to create another variable for the full path and concatenate the path to the report name there instead of doing so in the DoCmd.
Hope this helps,
beacon
NeoPa 32,556
Recognized Expert Moderator MVP
You're using the + character for concatenation, which is unreliable as it returns a value of Null if either of the values it joins is Null (See Using "&" and "+" in WHERE Clause for a full explanation).
If you use the & character instead then you will at least see what is missing : - strReportName = [Name] & "-" & [Hypérion] & ".pdf"
Also check the actual name of the field. Is it actually [ Hypérion], or might it be [ Hyperion]?
Hello,
Thanks to you all for replying,
@ Beacon
No error message received
@ Neopa
've changed "+" to "&" to be sure
@ thesmileycoder
‘ve changed fieldname “Name” to “Cust” and linked form to recordsource. This resolves problem but generates a new one :(
Unfortunately when saving, it takes always first record from record source for every report.
So, I suppose a filter is needed or another syntax code with a condition referring to the used reference in combobox (combo8)???
How do I have to write it down? and where? - Private Sub Command13_Click()
-
Dim myPath As String
-
Dim strReportName As String
-
DoCmd.OpenReport "Rep Hyperion recon ", acViewPreview, , "[SAP]=" & Me![Combo8], acWindowNormal
-
-
myPath = "S:\Accounts\Reconciliations\Recon letters\"
-
strReportName = [Cust] & " " & [Hypérion] & ".pdf"
-
DoCmd.OutputTo acOutputReport, "Rep Hyperion recon", acFormatPDF, myPath + strReportName, True
-
-
DoCmd.Close acReport, "Rep Hyperion recon"
-
-
End Sub
Have a nice day
Ok, so you open a report with a filter based on [SAP]. What is SAP and is it in any way related to Cust and Hyperion? Could you give some more details on your combo8, like its rowsource, as well as the field types used for cust, Hyperion, SAP?
Just to clarify, its does not take the FIRST record, it takes the ACTIVE record, which if you have not done anything to scroll through records, will of course be the FIRST record.
On another note, I strongly urge you to ALWAYS give every object you use a sensible name. Instead of combo8, it could be cmb_SelectSAP.
It may seem trivial at this point to keep track of your few objects, but it will get harder down the road, and getting used to simply always renaming objects will save you alot of grief.
Hi again,
Purpose of the report is to give an overview of all open invoices into accounting of our entities.
Starting from 2 excel files:
the 1st containing all references of entities (Hyperian Accounts) SAP: customer nr from our ERP (sap) system Hyperion: our coorporate recognize every entity with a different IDnr called Hyperion Cust: Name of the entity 2nd excel file represents overview of documents (Accounts Statements):
sap(same as before), invoice nr, invoice date, duedate, amount.
1 query (Qry Hyperion)based on those excel files with a relationship on [SAP].
1 form: with recordsource set on DB Hyperion Account 1 combobox (badly named combo8) with row source SELECT [Hyperion accounts].[SAP] FROM [Hyperion accounts] ORDER BY [SAP]; 1 button: need to run code as set before So I select "customer nr [SAP]" from list. By clicking on the button
my report "Rep Hyperion recon" opens and appears only with filtered information.
the rest remains the same as before.
I'll try change names as you requested as soon as possible
Hope you get enough information
Kind regards
Ok, so this is what I would do:
Change the rowsource of the combobox to: - SELECT SAP,Cust,Hyperion
-
FROM [Hyperion accounts]
-
ORDER BY [SAP];
Now the code can get easy access to the information Hyperion and Cust from the combobox like so: - strReportName = Me.cmb_SelectSap.Column(1) & "-" & Me.cmb_SelectSap.Column(2) & ".pdf"
(Just for clarity, column(0) is the SAP number)
Just apply all needed changes and it works fine.
Many thanks.
Hope this topic will give an answer to other users too
Thats very nice to hear.
PS. I just want to compliment you on your initial question. For a first time poster that is very good description you provided, as well as appropriate details, and follow up posts in which you reply to all posters, and adress the issues raised. It makes a world of difference in the motivation to help.
NeoPa 32,556
Recognized Expert Moderator MVP
I agree with that. And intelligent responses too. Always more fun to deal with :-)
NeoPa 32,556
Recognized Expert Moderator MVP
Another post was added here by the OP but it was a new question so it's been moved to its own thread - Saving Access Reports as PDFs.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Nicola |
last post by:
Hi Everyone,
I am new to programming and would like to know how to
open an access Report from within vb 6. I am trying to write a program
to organise cross stitch threads. I have found out how...
|
by: Tom Weddell |
last post by:
Can I call an Access report from VB.Net? (I'm using access as the backend.)
Thanks in advance.
|
by: Mark C |
last post by:
All,
I have exhaustingly been looking through the newsgroups in search of a way
to systemically output an Access 97 report to a pdf file using the full
version of Adobe Acrobat. I want the user...
|
by: Mike MacSween |
last post by:
tblCourses one to many to tblEvents.
A course may have an intro workshop (a type of event), a mid course
workshop, a final exam. Or any combination. Or something different in the
future.
At...
|
by: Pradeep Varma |
last post by:
Hi,
I am using Acrobat 6.0. I am trying to save an Access report to a PDF
file using the Acrobat Distiller but came across an error message
“ActiveX component cannot create object –429”. I have...
|
by: keithsimpson3973 |
last post by:
Does anyone know, and if so can they give me an idea of how to do it, if the following is possible....
My access report is based on a start date and stop date. What I would like to do is have vb6...
|
by: DeniseY |
last post by:
I have an Access report that is created on the fly by the user selecting the fields to be included. The Access report comes out fine, but I want it to automatically output to an Excel spreadsheet....
|
by: amanda27 |
last post by:
Hi there
I have an Access 2003 report that has different information for different projects my department is working on. It gives the status of the projects weekly. For each project they have a...
|
by: smorrison64 |
last post by:
I have a form that is coded to open a File Dialog boc to pick a picture to display on that particular item on a subform. My form is not based on query, but rather two separate tables (one primary,...
|
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= |
last post by:
I am using reporting service with asp.net.
I want to save a report snapshot in some time.
How do I do this in asp.net? Is there any web service to do this?
Thanks in advance!
-Billy
|
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: 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: 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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |