Insert records of an array

Kronosds

New member
Local time
Today, 12:44
Joined
Jun 11, 2017
Messages
9
Hello there, best regards to all,

I have a new problem with an array at the moment of insert records in my table, display me of error "3078, The database engine can not find the table or query of input false"

But my table if exist in my database, what can be the mistake? this is the code:

Code:
strPathcsv= .SelectedItems(1)
        
        rst.CursorLocation = adUseClient
    
    strNewPath = Left(strPathcsv, InStrRev(strPathcsv, "\") - 1) & "]." & Mid(strPathcsv, InStrRev(strPathcsv, "\") + 1)
    
    rst.Open "SELECT Top 10 * FROM [Text;Database=" & strNewPath & ";", CurrentProject.Connection, adOpenStatic, adLockReadOnly
                                      
    'Array
    ReDim flds(rst.Fields.Count - 1 - 14)
    For fld = 0 To UBound(flds)
        flds(fld) = fld + 14
    Next
    rst.Move 8 'Set focus un records 9
    tbl = rst.GetRows(2, , flds)
    rst.Close
    For fld = 0 To UBound(tbl, 1)
        CurrentDb.Execute _
        "Insert Into MyTable (C1, C2, C3, C4, C5, C6, C7, C8, C9, C10) " & _
        "Select '" & Left(tbl(fld, 0), 8) & "', '" & Right(tbl(fld, 1), 2) & "', F1, F2, F3, F9, F11, F7, F8, F10 From [Text;Database=" & strPathcsv = Where & F & fld + 1 + 14 & "='X'"
    Next

I thank you for the help you can give me....!

Kronosds
 
Common mistake, should be:

"Insert Into " & MyTable & " rest of code"
 
Now error is in this line:

Code:
'CurrentDb.Execute
        Debug.Print _
        "Insert Into & MyTable & (C1, C2, C3, C4, C5, C6, C7, C8, C9, C10) " & _
        "Select '" & Left(tbl(fld, 0), 8) & "', '" & Right(tbl(fld, 1), 2) & "', F1, F2, F3, F9, F11, F7, F8, F10 From [Text;Database=strPathcsv Where F" & fld + 1 + 14 & "='X'"

Debug.Print show:

Insert Into & MyTable & (C1, C2, C3, C4, C5, C6, C7, C8, C9, C10) Select '33207488', '1', F1, F2, F3, F9, F11, F7, F8, F10 From [Text;Database=strPathcsv Where F15='X'

I could not find the error :banghead:
 
I think you need text delimiters around strPathcsv as shown in RED

Code:
'CurrentDb.Execute
        Debug.Print _
        "Insert Into & MyTable & (C1, C2, C3, C4, C5, C6, C7, C8, C9, C10) " & _
        "Select '" & Left(tbl(fld, 0), 8) & "', '" & Right(tbl(fld, 1), 2) & "', F1, F2, F3, F9, F11, F7, F8, F10 From [Text;Database=[COLOR="Red"]'" & [/COLOR]strPathcsv [COLOR="red"]& "' [/COLOR]Where F" & fld + 1 + 14 & "='X'"
 
FROM [Text;Database=path;

Doesn't make sense. You haven't provided a table name and the brackets aren't closed.

FROM [path].


somestring = "... from [" & path & "].[" & table & "]"

Edit: kudos for making me Google getrows.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom