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 1980 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, ,...
|
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...
|
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. ...
|
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...
|
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...
| |
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...
|
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...
|
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",...
|
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...
|
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: 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 ...
| |