Hello all-
I'm a novice w/ VBA, but I know it's the solution to my problem. I have a bunch of files that are tab delimited, however they have no file extension, so I cannot create a import spec with them into Access. What I need to do is read through each line of the file, delete some rows, and add data to a table from the valid rows.
My files look like this:
Accepted Files[]
Approved[]
Acct#[] Name[] Desk[] Field1[] Field2[]
132131[] John Doe[] R1[] GG[] BK003[]
(I used "[]" to stand for a tab marker since I'm not sure how to make them.)
To futher complicate this, after this grouping of data, there's 2 blank rows, then a similar set of data for a declined accounts!
Declined Files[]
Acct#[]Name[]Desk[]Field1[]Field2[]
I don't necessarily need everything (accepted and declined) in seperate tables, as I could create a query that could seperate the two- however, I would like to have the user open a File Picker from a form to select the file (file type has to be "*" as these files have no extension), then the VBA dump it all into a table. I tried to write as much as I could figure out:
Code:
Public Function getFileName(tfile) As String
Dim fDialog As Object
Set fDialog = Application.FileDialog(msoFileDialogOpen)
Dim tfile As Variant
Dim fileDate As Date
With fDialog
.AllowMultiSelect = False
.Title = "Please select one file"
.Filters.Clear
.Filters.Add "All Files", "*.*"
If .Show = True Then
For Each tfile In .SelectedItems
getFileName = tfile
Next
End If
End With
MsgBox (getFileName)
getFileName = CStr(getFileName)
End Function
That allows me to open the file picker, but not sure what to do next. Any help would be greatly appreciated!