Hello,
I have created a subroutine that allows the user to select the file that they are going to import into the Access database.
My issue is that after the file is selected, the variable is displaying the complete path and file name, but I am getting an error that stated:
"Run-Time error '3011':
The Microsoft Access database engine could not find the object <file name> . Make sure the object exists and that you spell its name and the path correctly.
The <file name> is not showing the path, but the string field that I used in the statement does have the path and the file name.
What am I missing? Here is the subroutine:
Thanks for your help in advance!!
Eddi Rae
I have created a subroutine that allows the user to select the file that they are going to import into the Access database.
My issue is that after the file is selected, the variable is displaying the complete path and file name, but I am getting an error that stated:
"Run-Time error '3011':
The Microsoft Access database engine could not find the object <file name> . Make sure the object exists and that you spell its name and the path correctly.
The <file name> is not showing the path, but the string field that I used in the statement does have the path and the file name.
What am I missing? Here is the subroutine:
Code:
Private Sub cmdPW_Click()
Dim fDialog As Office.FileDialog
Dim varFile As Variant
Dim sFileName As String
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryDeleteCMSTransferFile"
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
' Allow user to make multiple selections in dialog box '
.AllowMultiSelect = False
' Set the title of the dialog box. '
.Title = "Please select the CMS Transfer File that you want to check"
' Clear out the current filters, and add our own.'
.Filters.Clear
.Filters.Add "All Files", "*.*"
' Show the dialog box. If the .Show method returns True, the '
' user picked at least one file. If the .Show method returns '
' False, the user clicked Cancel. '
If .Show = True Then
'Loop through each file selected and add it to our list box. '
For Each varFile In .SelectedItems
DoCmd.TransferText acImportFixed, "tblCMSTransferFile Import Specification", "tblCMSTransferFile", varFile, vbNo
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
DoCmd.OpenQuery "qryPremiumWithhold"
DoCmd.SetWarnings True
MsgBox "Process has Completed"
End Sub
Thanks for your help in advance!!
Eddi Rae