Hi,
I need help with following:
Currently i have a browse and read file procedure where the user can select files which are read into a table. Each file contains 14 columns but after read into table each table contains 15 fields. I want field #15 to contain an integer value which identifies each file type that is read into the table.
How would i go on doing that and how and where do i implement that into my code? (see below)
I made a 'try' which are the commented rows but those doesnt work unfortunatly. (notice im new to vba). Name of table is parameters and name of field #15 is FileType.
Really need help and appreciate any help i can get, thanks.
I need help with following:
Currently i have a browse and read file procedure where the user can select files which are read into a table. Each file contains 14 columns but after read into table each table contains 15 fields. I want field #15 to contain an integer value which identifies each file type that is read into the table.
How would i go on doing that and how and where do i implement that into my code? (see below)
I made a 'try' which are the commented rows but those doesnt work unfortunatly. (notice im new to vba). Name of table is parameters and name of field #15 is FileType.
Really need help and appreciate any help i can get, thanks.
Code:
Option Compare Database
Private Sub Command0_Click()
If MsgBox("This will open the folder for imports. Continue?", vbYesNoCancel) = vbYes Then
Dim i As Integer
Dim tblStr As String
Dim varItem As Variant
Dim specname As String
Dim mySQL As String
Dim aob As AccessObject, obj As Object
i = 1
tblStr = ""
specname = "Import Specs"
Set obj = CurrentData.AllTables
With Application.FileDialog(msoFileDialogFilePicker)
With .Filters
.Clear
.Add "All Files", "*.*"
End With
.AllowMultiSelect = True
.InitialFileName = "C:\Users\Database\Readlog"
.InitialView = msoFileDialogViewDetails
If .Show Then
For Each varItem In .SelectedItems
'Shell ("C:\Users\Database\Readlog\readlog.exe C:\Users\Database\Readlog\varItem")
For i = 1 To Len(varItem)
If IsNumeric(Mid(CStr(varItem), i, 1)) Then
tblStr = tblStr & Mid(CStr(varItem), i, 1)
End If
Next i
If Right(CStr(varItem), 4) = ".txt" Then
DoCmd.TransferText acImportDelim, specname, "parameters", CStr(varItem), True
i = i + 1
DoCmd.OpenTable "parameters", acViewNormal, acReadOnly
DoCmd.Close
tblStr = ""
End If
'For Each aob In obj
'If Right(CStr(varItem), 7) = "D02.txt" And Left(aob.Name, 10) = "parameters" Then
'mySQL = "INSERT INTO Parameters ((FileType) VALUES (0));"
'DoCmd.RunSQL mySQL
'End If
'Next
Next varItem
MsgBox "Data Transferred Successfully!"
DoCmd.Close
End If
End With
End If
End Sub
Comment