Thanks orange that video was extremely helpful!
I mimicked his process as I followed along to help me understand it, then I watched a second time while building my own form to accomplish what I need but I have one question:
How can I pull the result of my sub into the [FileName] portion of my function?
I have so far:
- Sub btnBrowseAllPoints_Click() that selects the .csv using a OpenFileDialog
- Function ImportAllPoints() that should import the table after it has been selected using the above sub using a DoCmd.TransferText
See the sub and function below:
Code:
Public Function ImportAllPoints()
DoCmd.TransferText acImportDelim, , "tblAllPointsImport", [FileName], False
End Function
Code:
Private Sub btnBrowseAllPoints_Click()
Dim filter As New DialogFilter
Dim result As OpenFileDialogResult
filter.Description = "Delim. Files"
filter.Extensions = "*.csv, *.txt"
Set result = FileUtilities.OpenFileDialog("Select a file to import", False, filter)
If result.Successful Then
Me.txtFileAllPoints = result.FileName
Else
Me.txtErrorMessage = result.ErrorMessage
Me.txtErrorMessage = Null
End If
End Sub
There are also two Class Modules being used here:
Code:
Option Compare Database
Option Explicit
Public Description As String
Public Extensions As String
Code:
Option Compare Database
Option Explicit
Public Successful As Boolean
Public ErrorMessage As String
Public FileName As String
Very close to solving this question. Any advice would be greatly appreciated.