' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Sub loadfile(filnam As String, tblnam As String, value As Integer)
    Dim line As String
    Dim fields
    Dim sql As String
    Open filnam For Input As #1
    Do While Not EOF(1)
        Line Input #1, line
        fields = Split(line, ",")
        sql = "INSERT INTO " & tblnam & " VALUES (" & fields(0) & ",'" & fields(1) & "','" & fields(2) & "','" & fields(3) & "'," & Str(value) & ");"
        DoCmd.RunSQL sql
    Loop
    Close #1
End Sub

Function testloadfile()
   Call loadfile("C:\test.dat", "tblDataFile", 123)
End Function
