Hamish 237
New member
- Local time
- Today, 18:58
- Joined
- Jun 19, 2019
- Messages
- 16
Hi All im having issues with this bit of code can anyone assist with what i'm missing / doing wrong hopefully its something simple im just over looking or not familiar with I'm getting a Type Mismatch alert when i run the code. checking for a vbstring in the directory is where i think i'm getting it wrong
Code Tags Added by UG
Code Tags Added by UG
Code:
Private Sub Command20_Click()
On Error GoTo Command20_Click_Err
Dim Filepath As String
Dim strname As String
'Look for windows directory file path to see if it exists
'If it doesn't exist creates the directory file folder then saves Pdf file in it
'If directory exists check if file already present if file already exists alert operator file will be overwritten
'
Filepath = Application.CurrentProject.Path & "\" & Me.VHID.Column(1) & "\" & "Fault" & "\" & Me.CLID
strname = Application.CurrentProject.Path & "\" & Me.VHID.Column(1) & "\" & "Fault" & "\" & Me.CLID & "\" & Me.CLID & ".pdf"
'question does directory exists as per filepath
If Dir(Filepath, vbDirectory) = vbNullString Then
MkDir Filepath
DoCmd.OutputTo acOutputReport, "rClaimSUB", acFormatPDF, strname, False, , , acExportQualityPrint
Application.FollowHyperlink Filepath
Else
If Dir(strname, vbNormal) = vbString Then
If MsgBox("This file already exists do you want to replace file?", vbQuestion + vbYesNo, "Replace file") = vbYes Then
DoCmd.OutputTo acOutputReport, "rClaimSUB", acFormatPDF, strname, False, , , acExportQualityPrint
pplication.FollowHyperlink Filepath
Else
'Do Nothing
End If
Else
DoCmd.OutputTo acOutputReport, "rClaimSUB", acFormatPDF, strname, False, , , acExportQualityPrint
Application.FollowHyperlink Filepath
End If
End If
Command20_Click_Exit:
Exit Sub
Command20_Click_Err:
MsgBox Error$
Resume Command20_Click_Exit
End Sub
Last edited by a moderator: