Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Public Sub ImportFiles()
Const Folder = "[red]C:\My Documents[/red]" ' Path to your files
Const Extension = "[red]xxx[/red]" ' Your file extension
Const FileSpec = Folder & "\*." & Extension
Dim strFilePath As String, strFile As String
Dim db As DAO.Database, tdf As DAO.TableDef, qdf As DAO.QueryDef
Dim fn As Integer
On Error GoTo ErrorHandler
Set db = CurrentDb()
strFilePath = Dir(FileSpec)
Do While Len(strFilePath) > 0
strFile = Mid$(strFilePath, Len(Folder) + 2)
fn = fn + 1
SysCmd acSysCmdSetStatus, "Processing file #" & fn
Set tdf = db.TableDefs("MyLinkedFile")
tdf.Connect = "Text;DATABASE=" & Folder & ";TABLE=" & strFile
tdf.RefreshLink
Set tdf = Nothing
Set qdf = db.QueryDefs("MyImportQuery")
qdf.Execute
Set qdf = Nothing
strFilePath = Dir()
Loop
MsgBox "Import complete"
ErrorExit:
SysCmd acSysCmdClearStatus
Set qdf = Nothing
Set tdf = Nothing
Set db = Nothing
Exit Sub
ErrorHandler:
MsgBox "Runtime error (" & Err.Number & "):" & vbCr _
& Err.Description, vbExclamation
Resume ErrorExit
End Sub
4. If necessary, add a reference to the DAO library.
Dim db As DAO.Database
Function importfiles()
Dim FileName As String
FileName = ""
FileName = Dir("Path to the folder where the files are stored" & "*extension of the files i.e .xls")
If FileName <> "" Then
Do Until FileName = ""
DoCmd.TransferText acImportDelim, "1 Spec", "table1", " Path to the folder where the files are stored " & FileName, False, ""
End If
FileName = Dir()
End Function