J
john
Help!!!
I nned to import more than one file at a time when I
select Apr, May, etc.
Eg if I can import the following files, when I select Apr:
01 IWL Apr(5MG).txt
01 IWL Apr(5MH).txt
01 IWL Apr(5MJ).txt
This is the code as it stands....
Dim Create As Database, wl_import As Recordset, wl_cmds As
Recordset, int1 As Long, int2 As Long, i As Integer,
str_answer As String, str_filename As String
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
I nned to import more than one file at a time when I
select Apr, May, etc.
Eg if I can import the following files, when I select Apr:
01 IWL Apr(5MG).txt
01 IWL Apr(5MH).txt
01 IWL Apr(5MJ).txt
This is the code as it stands....
Dim Create As Database, wl_import As Recordset, wl_cmds As
Recordset, int1 As Long, int2 As Long, i As Integer,
str_answer As String, str_filename As String
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