Hi, the following code seem to work fine if the user picks a folder in the root drive. If they select the root HDD the strPathPDF becomes (eg M:\)
M:\\ProductList .pdf
The file gets created but is it correct?? What am I missing?
Thanks - Private Sub cmdCreatePDF_Click()
-
On Error GoTo ErrorHandler
-
-
Dim strWHERE As String
-
Dim strPathPDF As String
-
Dim reportName As String
-
Dim fDlg As Object
-
-
Set fDlg = Application.FileDialog(4)
-
-
If Not IsNull(Me.ctlHomeChild.Form!ProductID) Then
-
strWHERE = Me.ctlHomeChild.Form.Filter 'Use the filter from the calling form.
-
reportName = "rptProductList"
-
-
With fDlg
-
.Title = "Select a folder"
-
.AllowMultiSelect = False
-
.InitialFileName = "C:\"
-
If .Show = -1 Then
-
strPathPDF = .SelectedItems(1) & "\" & "ProductList.pdf"
-
-
Debug.Print strPathPDF
-
-
DoCmd.OpenReport reportName, acViewReport, , strWHERE, acHidden
-
-
With Reports(reportName)
-
Caption = "Product List Report " & Date
-
.FilterOn = True
-
End With
-
-
DoCmd.OutputTo acOutputReport, reportName, acFormatPDF, strPathPDF, False, , , acExportQualityPrint
-
DoCmd.Close acReport, reportName
-
-
End If
-
End With
-
Else
-
Beep
-
End If
-
-
exitSub:
-
Exit Sub
-
ErrorHandler:
-
MsgBox "Error No: " & Err.Number & vbNewLine _
-
& "Error Details: " & Err.Description & vbNewLine _
-
& "Error in Sub: frmProducts_Database\cmdCreatePDF_Click"
-
Resume exitSub
-
-
End Sub
5 1989 twinnyfo 3,653
Recognized Expert Moderator Specialist
Neruda,
I'm not sure we can answer your question: Neruda:
The file gets created but is it correct??
We don't know if it is correct. are you getting reports from your users that the files is incorrect? This is where we must start.
ADezii 8,834
Recognized Expert Expert
It is because you are appending a Trailing Backslash to the Selected Folder (.SelectedItems (1)) which would not be appropriate should it be the Root Folder (C:\). Insert Lines 180 - 220 to correct this. This Code Segment could be shortened, but I kept it in this format for illustration purposes. Some Code has also been omitted. - 100 Dim strPathPDF As String
-
110 Dim fDlg As Object
-
-
120 Set fDlg = Application.FileDialog(4)
-
-
130 With fDlg
-
140 .Title = "Select a folder"
-
150 .AllowMultiSelect = False
-
160 .InitialFileName = "C:\"
-
170 If .Show = -1 Then
-
180 If Right$(.SelectedItems(1), 1) = "\" Then
-
190 strPathPDF = .SelectedItems(1) & "ProductList.pdf"
-
200 Else
-
210 strPathPDF = .SelectedItems(1) & "\" & "ProductList.pdf"
-
220 End If
-
230 End If
-
240 End With
@twinnyfo
Hi What I mean I expected the path to be M:\
But I end up with M:\\
But it seems id does not make much difference, even if the path is M:\\\\\\\ it works just fine. I was just wondering if I was missing something in the code
I changed it as suggested anyway, thank u ADezii
ADezii 8,834
Recognized Expert Expert
You're welcome, good luck with your Project!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Frank Barnhart |
last post by:
We have an application which runs Access under automation.
With Access 97, the app included this line to send a report to a text
file:
myAccessObject.DoCmd.OutputTo acOutputReport, , acFormatTXT,
"sample.txt"
(The constant acOutputReport has the value of "MS-DOS Text (*.txt)".
There is no object name in the command because the report is open at
the time this line is executed.)
|
by: Robert Langen |
last post by:
I'm calling an Access XP application from an Outlook XP appointment form.
Everything works, but the lines
DoCmd.OutputTo acOutputReport, "testreport", acFormatRTF, "c:\test.rtf",
False
Docmd.Quit
produce Access hangs. That means, the file testreport.rtf is correctly
created, but Access doesn´t quit. The process msaccess.exe stays and
consumes 98% processor time. If I remove the OutputTo line, Access quits
perfectly.
|
by: Ryan |
last post by:
Hello. I was hoping that someone may be able to assist with an issue
that I am experiencing. I have created an Access DB which imports an
Excel File with a particular layout and field naming. Next the user
can go into a Form which basically a dynamic query with a friendly
interface that eventually outputs a table that is stored in the DB as
well as exported to a CSV file. The CSV file is then used with a
vendor solution to fill in...
|
by: ljungers |
last post by:
I need to make some changes to a Query/select/print report using word application. What I need to do is change the way Word is called yet keep the process the same. Word is used so changes can be made before actual printing. Need some way of calling Word as a mail merge with the information from an Access table that the current report uses.
I have seen mail merge templates that use something like <<field name>> in them that uses a table....
|
by: Simon |
last post by:
Dear reader,
With the DoCmd.OutputTo ...... you have the possibility to write a
report to an external location.
In case the external location is an existing file the DoCmd is not
responding with the warning "File already exist". The file will be overwrite
without any warning even with the DoCmd.Setwarnings True in
| |
by: inika301 |
last post by:
Mr Lebans. Could you help me ? We are trying to run your mdb to
convert access reports to pdf but we can not, because an error
happens. We are just using the A2000SnapShotToPDFver751 that is
abailable for downloading.
I have copied the two dlls to windows/system32 and they are too in the
same path as the mdb.
I have debuged your code and in the proc.ConvertReportToPDF when
running command DoCmd.OutputTo... an error occurs.
|
by: jmartmem |
last post by:
Greetings,
I have several Access 2007 reports that I regularly export to individual PDF flat files on a web server. I've successfuly created a module sub to export the reports using the DoCmd.OutputTo Macro action, but I can't seem to figure out how to run the macro automatically.
I can succesfully run the macro below manually (without the IF statements), but have yet to make it work with the IF statement. Ideally, the macro will run...
|
by: James Bowyer |
last post by:
I need to only print one page of a report, not the whole thing, but do so automatically. Annoyingly, I can't seem to get it to work!
This:
DoCmd.OutputTo acOutputReport, "rptmouldcurrent", acFormatPDF, "C:\Temp\Test.pdf", False
works ok, but prints out all reports, not just the one I want.
So, I tired this:
|
by: ChipStewart |
last post by:
I'm trying to use a few posts from this forum, including use DoCmd.OutputTo to export a PDF of the current record on a report? to send a single record displayed in a form of my potential client data to a text file to use with Outlook and QuickBooks. I have a button on the form and the following code:
Private Sub Export_Potential_Client_Data_Click()
On Error GoTo Err_Export_Potential_Client_Data_Click
Dim stDocName As String
...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |