Snowflake68
Registered User.
- Local time
- Today, 11:43
- Joined
- May 28, 2014
- Messages
- 464
I have the following code which imports a CSV file from a hard coded directory and filename (which is created dynamically) but I now need to change it so that the user receives a prompt to select the file they would like to import from a hard coded directory.
This is my current code which works a treat
The file is a CSV file in a set format so the user knows that the file needs to be in this format but they need to be able to be able to import the file of their choosing.
I found this code on the web but I don't really know how to use it.
Is someone able to help me please. As I replaced my Docmd.Transfertext line to that of the new code (above) but I just get an error message which I dont understand.
Run-time error '-2147467259(80004005)';
Method 'FileDialog' of object _Application' Failed
the above error points at this line of code
I am not an expert and I dont pretend to be so all help is grateful received.
This is my current code which works a treat
Code:
Dim strFilepath As String
strFilepath = [Application].[CurrentProject].[Path] & "\DE_Data\Portfolio\IN\PortFolioTemplate_" & DLookup("[CustomerFileName]", "1_CustomerProspectSelection") & "_" & DLookup("[LISTREFERENCE]", "LookupListRef") & ".CSV"
DoCmd.TransferText acImportDelim, "PortFolioTemplate_Import Specification", "tbl_Import_Portfolio_Template_ALL" ',strFilepath
The file is a CSV file in a set format so the user knows that the file needs to be in this format but they need to be able to be able to import the file of their choosing.
I found this code on the web but I don't really know how to use it.
Code:
Dim fileName As Variant
Dim strFileName As String
Set fileName = Application.FileDialog(msoFileDialogOpen)
If fileName.Show Then
strFileName = fileName.SelectedItems(1)
DoCmd.TransferText acImportDelim, "", "tbl_Import_Portfolio_Template_ALL", strFileName, True
End If
Is someone able to help me please. As I replaced my Docmd.Transfertext line to that of the new code (above) but I just get an error message which I dont understand.
Run-time error '-2147467259(80004005)';
Method 'FileDialog' of object _Application' Failed
the above error points at this line of code
Code:
Set fileName = Application.FileDialog(msoFileDialogOpen)
I am not an expert and I dont pretend to be so all help is grateful received.