Shelby,
I have included below a section of script that I have taken from one of my forms.... some of it you won't need...
it uses the file dialog to open a file select window... you will see there are some filters and things on there....
you should be able to work out the bits you need from it.
hope it helps
Max
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strfilename As String
Dim strsql As String
Dim fDialog As Office.FileDialog
Dim varFile As Variant
Set db = CurrentDb
strsql = "delete * from Atlantis"
db.Execute strsql
' Set up the File dialog box.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
' Allow the user to make multiple selections in the dialog box.
.AllowMultiSelect = True
' Set the title of the dialog box.
.Title = "ATLANTIS FILES!!"
' Clear out the current filters, and then add your own.
.Filters.Clear
.Filters.Add "Comma Seperated", "*.CSV"
.Filters.Add "Text", "*.txt"
.Filters.Add "All Files", "*.*"
' Show the dialog box. If the .Show method returns True, the
' user picked at least one file. If the .Show method returns
' False, the user clicked Cancel.
If .Show = True Then
' Loop through each file that is selected and then add it to the list box.
For Each varFile In .SelectedItems
'check file not already been loaded
strsql = "select * from filelog where filename='" & varFile & " '"
Set rs = db.OpenRecordset(strsql, dbOpenDynaset)
'If file not already loaded start load process
If rs.EOF Then
DoCmd.Hourglass (True)
DoCmd.TransferText acImportDelim, "Atlantis", "Atlantis", varFile
strsql = "select name from MSysobjects where name like '*_importErrors'"
Set rs = db.OpenRecordset(strsql, dbOpenDynaset)
Do While Not rs.EOF
DoCmd.DeleteObject acTable, rs!Name
rs.MoveNext
Loop
rs.Close
Set rs = db.OpenRecordset("Filelog", dbOpenTable)
With rs
.AddNew
rs!Filename = varFile
rs!load_Date = Now()
.Update
End With
rs.Close
Set rs = Nothing
DoCmd.Hourglass (False)
Else
'notify user file already loaded
MsgBox "The Atlantis File " & varFile & "Has Already Been Loaded", vbInformation
End If
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
Set fDialog = Nothing
db.Close
Set db = Nothing
End Sub