silentwolf
Active member
- Local time
- Today, 00:03
- Joined
- Jun 12, 2009
- Messages
- 644
Hi guys,
I have a code to import CSV Files into my Database. All works well. However what I like to do is change the FileName or Update the FileName prior to import.
As some FileNames are not in the correct nameing convention for the import I was thinking of changing the FileName automatically and then import.
For Example.
The User picks a file with the Name: "C:\Documents\MyFile-01-12-12-2021.csv"
I can't import the file as there are characters not allowed to do so.
Is there a way to change the fileName prior to the import automatically?
When the user clicks on "btnDataImport" that it checks whether it is a valid name if it is then import else save as "newFileName" and close the Form.
Above just a simple code to import...
Hope that Error Handling is ok like that?
Is there a way I could check if the FileName is Valid for the import and if not than change it accordingly and perhabs saveAs "NewFileName" end close the form?
Or how would you go about it?
Cheers and hopefully I explained it correctly?
I have a code to import CSV Files into my Database. All works well. However what I like to do is change the FileName or Update the FileName prior to import.
As some FileNames are not in the correct nameing convention for the import I was thinking of changing the FileName automatically and then import.
For Example.
The User picks a file with the Name: "C:\Documents\MyFile-01-12-12-2021.csv"
I can't import the file as there are characters not allowed to do so.
Is there a way to change the fileName prior to the import automatically?
When the user clicks on "btnDataImport" that it checks whether it is a valid name if it is then import else save as "newFileName" and close the Form.
Code:
Public Sub ImportCSVFile(FileName As String)
On Error GoTo Err
DoCmd.TransferText acImportDelim, "VBAuszug", TableName, FileName, True, , 1252
Exit_Import:
Exit Sub
Err:
MsgBox "Die Datei hat keinen gültigen Namen bitte Dateiname ändern!", vbCritical
Resume Exit_Import
End Sub
Above just a simple code to import...
Hope that Error Handling is ok like that?
Is there a way I could check if the FileName is Valid for the import and if not than change it accordingly and perhabs saveAs "NewFileName" end close the form?
Or how would you go about it?
Cheers and hopefully I explained it correctly?