S
Sash
I'm being a pain today, but trying to address all the issues with my
database.
I use the following to allow my customer to select and load multiple files.
My issue is that if they click yes and then get to the selection window and
click cancel, the program gives me an error message and stops. How could I
put something in that indicates if cancel is hit, leave the loop.
'***** ABC Company *****
If Me!Frame50.Value = 9 Then
strClient = "ABCCo"
strClientNum = "170"
'Drop All Records from Current Table
strSQLDrop = "DELETE * from ABCCo"
DoCmd.RunSQL strSQLDrop
'GetFile
Dim vbMsgBoxResultSA As Long
vbMsgBoxResultSA = vbYes
Do While vbMsgBoxResultSA = vbYes
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Select Import File"
.Filters.Clear
.Filters.Add "Text", "*.txt"
.Filters.Add "All Files", "*.*"
.FilterIndex = 1
.AllowMultiSelect = False
.InitialFileName = "\u:interfaces/import/"
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))
End If
End With
strOrigFile = Mid(fileName, 22, 30)
'Trim File Header
Call TrimFileHeaderX(fileName, 1)
'Load with Specs
stSpecs = "ABCCo Import"
sttable = "ABCCo"
stfilename = fileName
stQuery1 = "ABCCo_UpdateIN1Name"
stquery2 = "ABCCo_UpdateIN2Name"
stquery3 = "ABCCo_UpdateIN3Name"
DoCmd.TransferText acImportDelim, stSpecs, sttable, stfilename
DoCmd.OpenQuery stQuery1
DoCmd.Close acQuery, stQuery1
DoCmd.OpenQuery stquery2
DoCmd.Close acQuery, stquery2
DoCmd.OpenQuery stquery3
DoCmd.Close acQuery, stquery3
'Ask Another Import if so, GOTO GetFile and loop until user says NO
vbMsgBoxResultSA = MsgBox("Load Another File?", vbYesNo)
'Move File to Archive
FileCopy stfilename, "u:\interfaces\import\archive\ABCCo\" & "_" &
Format(Time, "HHMMSS") & strOrigFile
Kill stfilename
Loop
*****rest of program ******
database.
I use the following to allow my customer to select and load multiple files.
My issue is that if they click yes and then get to the selection window and
click cancel, the program gives me an error message and stops. How could I
put something in that indicates if cancel is hit, leave the loop.
'***** ABC Company *****
If Me!Frame50.Value = 9 Then
strClient = "ABCCo"
strClientNum = "170"
'Drop All Records from Current Table
strSQLDrop = "DELETE * from ABCCo"
DoCmd.RunSQL strSQLDrop
'GetFile
Dim vbMsgBoxResultSA As Long
vbMsgBoxResultSA = vbYes
Do While vbMsgBoxResultSA = vbYes
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Select Import File"
.Filters.Clear
.Filters.Add "Text", "*.txt"
.Filters.Add "All Files", "*.*"
.FilterIndex = 1
.AllowMultiSelect = False
.InitialFileName = "\u:interfaces/import/"
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))
End If
End With
strOrigFile = Mid(fileName, 22, 30)
'Trim File Header
Call TrimFileHeaderX(fileName, 1)
'Load with Specs
stSpecs = "ABCCo Import"
sttable = "ABCCo"
stfilename = fileName
stQuery1 = "ABCCo_UpdateIN1Name"
stquery2 = "ABCCo_UpdateIN2Name"
stquery3 = "ABCCo_UpdateIN3Name"
DoCmd.TransferText acImportDelim, stSpecs, sttable, stfilename
DoCmd.OpenQuery stQuery1
DoCmd.Close acQuery, stQuery1
DoCmd.OpenQuery stquery2
DoCmd.Close acQuery, stquery2
DoCmd.OpenQuery stquery3
DoCmd.Close acQuery, stquery3
'Ask Another Import if so, GOTO GetFile and loop until user says NO
vbMsgBoxResultSA = MsgBox("Load Another File?", vbYesNo)
'Move File to Archive
FileCopy stfilename, "u:\interfaces\import\archive\ABCCo\" & "_" &
Format(Time, "HHMMSS") & strOrigFile
Kill stfilename
Loop
*****rest of program ******