Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2008
    Posts
    1

    Unanswered: Syntax Error 3134, INSERT INTO statement

    My field names for tblUserDatabase:

    EmployeeID - AutoNumber
    strStatus - Text
    strTess - Text
    strConv - Text
    strClean-Delete - Text
    strPIctureFilename - Text
    strComments - Text

    And my code:

    Public Sub GetPictures()

    Dim strPicturePath As String

    strPicturePath = "C:\Documents and Settings\bchase\Desktop\Job_Request_&_Project_Deta ils_Form"

    AddFilenamesToTable (strPicturePath)

    End Sub

    Public Sub AddFilenamesToTable(folderspec)

    Dim fs, fsFolder, fsFile, fsListOfFiles
    Dim strFilename As String, strSQL As String

    Set fs = CreateObject("Scripting.FileSystemObject")
    Set fsFolder = fs.GetFolder(folderspec)
    Set fsListOfFiles = fsFolder.files

    For Each fsFile In fsListOfFiles
    strFilename = fsFile.Name
    If DCount("[EmployeeID]", "[tblUserDatabase]", "[strPictureFilename] = '" _ & strFilename & "'") = 0 Then
    strSQL = "INSERT INTO tblUserDatabase ( strPictureFilename, strConv, _ strClean-Delete, strTess, strStatus, strComments ) VALUES ('" & strFilename _ & "', #" & fsFile.DateLastModified & "# ) ;"
    CurrentDb.Execute strSQL
    End If
    Next

    End Sub


    When I debug it is highlighting "CurrentDB.Execute strSQL"

    Any suggestions? Thanks you in advance!

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi

    Debug.print the string before executing and see what its value is.

    Do you really have a field called "_ strClean-Delete"? That would fail for starters and should be seriously rethought.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Id agree with PKStormy that _ strClean-Delete is an accident waiting to happen. if you 'MUST' use spaces in a column name enclose the column name in [] eg [_ strClean-Delete]

    but to add to your probelms you don't have sufficnet vlaues to match the number of columns you specify

    strSQL = "INSERT INTO tblUserDatabase ( strPictureFilename, strConv, _ strClean-Delete, strTess, strStatus, strComments )
    VALUES ('" & strFilename _ & "', #" & fsFile.DateLastModified & "# ) ;"

    .. i make that 6 columns identified in the insert statement but only two values specified in the values section. Access/JET may be able to handle that, Im not sure.. but it certainly don't look right

    do you really want to update the vlaue of strfilename in "
    say the file name (strfilename was c:\path\to\image.ext
    you are trying to set the value as "c:\path\to\image.ext"

    just whilst we are referrign to column names.. you seriously prefixl your column name eith the data type?

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    that was TALC POOF not PKS.
    ...and yes: i also prefix field names with datatype hints.
    it costs absolutely nothing and i totally reject any suggestion that it makes reading code more difficult.

    izy
    currently using SS 2008R2

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    TALC POOF 3 actually
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •