INSERT integer value INTO existing table & column

CuriousGeorge

Registered User.
Local time
Today, 07:45
Joined
Feb 18, 2011
Messages
131
I made a halfway try to add an integer value into a column in my code below.

What i want to do:

Each file consists of 14 columns (or fields) and after being read in, the table contains 15 columns. I want to tag each file so that column #15 in the table contains an integer number depending on file type, which means that every row in column #15 should contain a number specific for each file type previously added.

How would i go on doing that?

Any ideas how to implement that?

Cheers!


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\SSS787\exjobb\Database\Readlog"
             .InitialView = msoFileDialogViewDetails
                    If .Show Then
                      For Each varItem In .SelectedItems
                        'Shell ("C:\Users\SSS787\exjobb\Database\Readlog\readlog.exe C:\Users\SSS787\exjobb\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
 
                       [COLOR=red]For Each aob In obj[/COLOR]
[COLOR=red]                         If Right(CStr(varItem), 7) = "D02.txt" And Left(aob.Name, 10) = "parameters" Then[/COLOR]
[COLOR=red]                         mySQL = "INSERT INTO Parameters ((FileType) VALUES (0));"[/COLOR]
 
[COLOR=red]                          DoCmd.RunSQL mySQL[/COLOR]
[COLOR=red]                          End If[/COLOR]
[COLOR=red]                      Next[/COLOR]
 
 
                    Next varItem
 
                      MsgBox "Data Transferred Successfully!"
                    DoCmd.Close
                    End If
      End With
  End If
 
End Sub
 

Users who are viewing this thread

Back
Top Bottom