Results 1 to 3 of 3
  1. #1
    kwooten is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    255

    Visual Basic

    Can someone help me with this error?

    Runtime Error "3061"
    Too Few Parameters. Expected 1.

    The debug goes to the red text below... my data loads to the table fine though.

    Sub ImportData()
    Dim sFileDir As String
    Dim fs
    Dim fsFolder
    Dim fsFile
    Dim sFileName
    Dim db As Database
    Dim sSQL As String
    Set db = CurrentDb
    Set fs = CreateObject("Scripting.filesystemobject")
    sFileDir = CurrentProject.Path & "\"
    Set fsFolder = fs.getfolder(sFileDir)
    For Each fsFile In fsFolder.files
    sFileName = fsFile.Name
    If Len(sFileName) = 11 Then
    If IsNumeric(Left(sFileName, 6)) Then
    If Right(sFileName, 5) = ".xlsx" Then
    Debug.Print sFileName
    DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, "tblImportedData", sFileDir & sFileName, True
    sSQL = "UPDATE tblImportedData SET OriginalFilename = '" & Left(sFileName, 6) & "' WHERE (isnull(OriginalFilename))"
    db.Execute sSQL
    End If
    End If


    End If
    Next
    Set fs = Nothing
    Set db = Nothing
    End Sub

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Just before the execute statement, put this : Debug.Print sSQL
    The SQL will then be displayed in the immediate window.
    Copy the string and paste it into an empty Create Query window
    Try and run it - you will be able to see what the error is.

  3. #3
    kwooten is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    255
    fixed it... thanks

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Using Access Instead of Visual Basic
    By dinz in forum Programming
    Replies: 2
    Last Post: 12-19-2019, 10:33 AM
  2. how to use visual basic in access
    By learning_graccess in forum Access
    Replies: 3
    Last Post: 12-05-2011, 03:23 PM
  3. Can't find Visual Basic
    By Art Burger in forum Programming
    Replies: 0
    Last Post: 04-20-2011, 05:35 PM
  4. Query in visual basic
    By Lucas83 in forum Programming
    Replies: 1
    Last Post: 06-10-2010, 11:00 AM
  5. Record Value in Visual Basic
    By chrismec in forum Programming
    Replies: 3
    Last Post: 12-09-2009, 04:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums