Wildcard help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a procedure that I'm having trouble including wildcard characters.
Here is my procedure without wildcard characters that works:

DataImport "C:\Trans\Fuel\05032006_0001.raw", "Fuel"

I would like to substitute wildcard characters for the 0001, but this
doesn't work.

DataImport "C:\Trans\Fuel\05032006_****.raw", "Fuel"

Any help would be greatly appreciated
 
Doug said:
I have a procedure that I'm having trouble including wildcard
characters. Here is my procedure without wildcard characters that
works:

DataImport "C:\Trans\Fuel\05032006_0001.raw", "Fuel"

I would like to substitute wildcard characters for the 0001, but this
doesn't work.

DataImport "C:\Trans\Fuel\05032006_****.raw", "Fuel"

Any help would be greatly appreciated

You'd have to post the code for the "DataImport" procedure, if you want
advice on how to modify it. Or else, you could do something like this,
working outside that procedure:

Dim strFolder As String
Dim strFile As String

strFolder = "C:\Trans\Fuel\"

' Get first matching file.
strFile = Dir(strFolder & "05032006_????.raw")

Do While Len(strFile) > 0

DataImport strFolder & strFile, "Fuel"

' Get next matching file.
strFile = Dir()
Loop
 
Dirk,

Thanks. Here is the DataImport procedure

Sub DataImport(strPath As String, strTableName As String)
'Variables used to create and modify the file extension
Dim objFileSystem
Dim objFile
Dim strFileCopy As String
Dim intExtPosition As Integer

'Create an instance of the FileSystemObject to access
'the local file system
Set objFileSystem = CreateObject("Scripting.FileSystemObject")

'Use the GetFile method to return a File object corresponding to the
'file in a specified path.
Set objFile = objFileSystem.GetFile(strPath)
intExtPosition = InStr(objFile.Name, ".")
If intExtPosition > 0 Then
strFileCopy = Left(objFile.Name, intExtPosition - 1) & ".txt"
Else
strFileCopy = objFile.Name & ".txt"
End If

'Create a copy of the file with a .txt extension
objFile.Copy strFileCopy, True
'DoCmd.TransferText acImportDelim, , strTableName, strFileCopy, True
DoCmd.TransferText acImportFixed, "OMSD Import Specification",
strTableName, strFileCopy, False, "", 437

End Sub
 
Back
Top