adammitchell23
Registered User.
- Local time
- Today, 10:11
- Joined
- Oct 30, 2017
- Messages
- 24
Hi folks,
This is a bit of a run-one from a previous post but I thought it was enough of a tangent to start a new thread.
I'm using the following code to enter filepaths from a dialog box into a text box on a form, which then tells an import routine which file to import using the transfertext method.
This works fine if I'm only trying to import a single file but if I multiselect, Access tries to read the multiple file paths as a single string in the text box and fails. I thought the semicolon would let it know it needs to be importing multiple files, but it seems I'm wrong...
Thanks all,
Ad
This is a bit of a run-one from a previous post but I thought it was enough of a tangent to start a new thread.
I'm using the following code to enter filepaths from a dialog box into a text box on a form, which then tells an import routine which file to import using the transfertext method.
Code:
Private Sub cmdSelectFile_Click()
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogOpen)
With fd
.AllowMultiSelect = True
If .Show Then
For i = 1 To fd.SelectedItems.Count
Me.txtFileName.Value = Me.txtFileName.Value & ";" & .SelectedItems.Item(i)
Next
End If
End With
End Sub
Public Function ImportWeather()
DoCmd.OpenForm "frmImport2", , , , , acDialog
RunImportProcedure Forms("frmImport2").Filename
DoCmd.TransferText acImportDelim, "ImportWeather", "tblWeatherImportTemp", Filename, True
End Function
Public Sub RunImportProcedure(ByVal Filename As String)
MsgBox "Importing your files..."
End Sub
Public Property Get Filename() As String
Filename = Me.txtFileName.Value
End Property
Private Sub clrList_Click()
Call clearListBox
Me!mySelections.Value = Null
End Sub
This works fine if I'm only trying to import a single file but if I multiselect, Access tries to read the multiple file paths as a single string in the text box and fails. I thought the semicolon would let it know it needs to be importing multiple files, but it seems I'm wrong...
Thanks all,
Ad