This is a code I have to find a file and import the file.
Dim Create As Database, wl_import As Recordset, wl_cmds As Recordset, int1 As Long, int2 As Long, str_answer As String, str_filename As String, i As Integer
Set Create = DBEngine.Workspaces(0).Databases(0)
Set wl_import = Create.OpenRecordset("WL CMDS (RNA00)"
Set wl_cmds = Create.OpenRecordset("WL NonRes"
With Application.FileSearch
.NewSearch
.LookIn = "K:\WL CMDS (Current Financial Year)_\Dudley Group of Hospitals NHS Trust\Inpatient Waiting _List CMDS"
'Below File needs to be updated each month with the _latest filename
str_answer = InputBox("What month?" & Chr(10) & Chr_(13) & Chr(10) & Chr(13) & "Please ensure the month is in _the abbreviated format ""Jan"" for January", _vbInformation, "Select Month"
Select Case str_answer
Case "Apr"
str_filename = "01 IWL Apr(QEE).txt"
Case "May"
str_filename = "02 IWL May(QEE).txt"
Case "Jun"
str_filename = "03 IWL Jun(QEE).txt"
Case "Jul"
str_filename = "04 IWL Jul(QEE).txt"
Case "Aug"
str_filename = "05 IWL Aug(QEE).txt"
Case "Sep"
str_filename = "06 IWL Sep(QEE).txt"
Case "Oct"
str_filename = "07 IWL Oct(QEE).txt"
Case "Nov"
str_filename = "08 IWL Nov(QEE).txt"
Case "Dec"
str_filename = "09 IWL Dec(QEE).txt"
Case "Jan"
str_filename = "10 IWL jan(QEE).txt"
Case "Feb"
str_filename = "11 IWL Feb(QEE).txt"
Case "Mar"
str_filename = "12 IWL Mar(QEE).txt"
Case Else
'unknown file name - would be better if _this problem was handled better
End Select
.FileName = str_filename
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
DoCmd.TransferText acImportFixed, "IPWL _04 RNA Import", "WL CMDS (RNA00)", .FoundFiles(i)
Next i
End If
End With
But no matter what I try it does not work. I checked and double checked the path and filename, but it passes through the code ok, but no file is imported. What am I doing wrong? I just can't seems to work it out, HELP!!!!
Dim Create As Database, wl_import As Recordset, wl_cmds As Recordset, int1 As Long, int2 As Long, str_answer As String, str_filename As String, i As Integer
Set Create = DBEngine.Workspaces(0).Databases(0)
Set wl_import = Create.OpenRecordset("WL CMDS (RNA00)"
Set wl_cmds = Create.OpenRecordset("WL NonRes"
With Application.FileSearch
.NewSearch
.LookIn = "K:\WL CMDS (Current Financial Year)_\Dudley Group of Hospitals NHS Trust\Inpatient Waiting _List CMDS"
'Below File needs to be updated each month with the _latest filename
str_answer = InputBox("What month?" & Chr(10) & Chr_(13) & Chr(10) & Chr(13) & "Please ensure the month is in _the abbreviated format ""Jan"" for January", _vbInformation, "Select Month"
Select Case str_answer
Case "Apr"
str_filename = "01 IWL Apr(QEE).txt"
Case "May"
str_filename = "02 IWL May(QEE).txt"
Case "Jun"
str_filename = "03 IWL Jun(QEE).txt"
Case "Jul"
str_filename = "04 IWL Jul(QEE).txt"
Case "Aug"
str_filename = "05 IWL Aug(QEE).txt"
Case "Sep"
str_filename = "06 IWL Sep(QEE).txt"
Case "Oct"
str_filename = "07 IWL Oct(QEE).txt"
Case "Nov"
str_filename = "08 IWL Nov(QEE).txt"
Case "Dec"
str_filename = "09 IWL Dec(QEE).txt"
Case "Jan"
str_filename = "10 IWL jan(QEE).txt"
Case "Feb"
str_filename = "11 IWL Feb(QEE).txt"
Case "Mar"
str_filename = "12 IWL Mar(QEE).txt"
Case Else
'unknown file name - would be better if _this problem was handled better
End Select
.FileName = str_filename
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
DoCmd.TransferText acImportFixed, "IPWL _04 RNA Import", "WL CMDS (RNA00)", .FoundFiles(i)
Next i
End If
End With
But no matter what I try it does not work. I checked and double checked the path and filename, but it passes through the code ok, but no file is imported. What am I doing wrong? I just can't seems to work it out, HELP!!!!