Results 1 to 7 of 7
  1. #1
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402

    Run Time error 3061

    Hi Everyone

    I have this code that runs from a buttons on click event.
    this is producing this error

    Run-Time error '3061'
    too few parameters. expected 2.

    the code stops at the red text

    any ideas,

    many thanks in advance

    Steve


    Dim LResponse As Integer
    'On Error GoTo Command75_Click_Error
    LResponse = MsgBox("Are You Sure you want to Duplicate This Asset?", vbYesNo, "Duplicate This Asset")
    If LResponse = vbYes Then
    'On Error GoTo Err_Handler
    'Purpose: Duplicate the main form record and related records in the subform.
    Dim strSql As String 'SQL statement.
    Dim lngID As Long 'Primary key value of the new record.

    'Save any edits first
    If Me.Dirty Then
    Me.Dirty = False
    End If
    'Make sure there is a record to duplicate.
    If Me.NewRecord Then
    MsgBox "Select the record to duplicate."
    Else
    'Duplicate the main record: add to form's clone.
    With Me.RecordsetClone
    .AddNew
    !AssetType = Me.AssetTypeCBO
    !Supplier = Me.SupplierCBO
    !WindowsLicence = Me.WindowsLicenceTXTBox
    !IPAddressType = Me.IPAddressTypeCBO
    'etc for other fields.
    .Update
    'Save the primary key value, to use as the foreign key for the related records.
    .Bookmark = .LastModified
    lngID = !AssetID
    'Duplicate the related records: append query.
    If Me.[ITHelpDeskEditAssetDetails].Form.RecordsetClone.RecordCount > 0 Then
    strSql = "INSERT INTO [Assetdetails] ( AssetID, AssetMakeID, AssetModelID, AssetModel, OS, Processor, memorySize, HardDriveSize, GraphicCard, MemorySizeType, HarddriveSizeType, Swan, MicrosoftOffice, Planet, Preactor, RedLionApp, SalesBase, SpindleSoftware, HelpDesk, ProductionDashboards, PDA, TMS, Unex, PhoneBook, EasyLabel, NetworkConnectionCard, NetworkConnectionType, PrinterType, PrinterSpeed, PrinterDesignType, ActiveDirectory, AntivirusSoftware, DHCP, DNS, BackupSoftware, ExchangeServer, SystemsDatabaseBackEndTables, PlanetDB, PDASystem, RaidType, NumberOfHardDrives, NumberOfHandsets, UPSPowerOutLets, UPSSerialPort, UPSUSBPort ) " & _
    "SELECT " & lngID & " As NewID, AssetMakeID, AssetModelID, AssetModel, OS, Processor, memorySize, HardDriveSize, GraphicCard, MemorySizeType, HarddriveSizeType, Swan, MicrosoftOffice, Planet, Preactor, RedLionApp, SalesBase, SpindleSoftware, HelpDesk, ProductionDashboards, PDA, TMS, Unex, PhoneBook, EasyLabel, NetworkConnectionCard, NetworkConnectionType, PrinterType, PrinterSpeed, PrinterDesignType, ActiveDirectory, AntivirusSoftware, DHCP, DNS, BackupSoftware, ExchangeServer, SystemsDatabaseBackEndTables, PlanetDB, PDASystem, RaidType, NumberOfHardDrives, NumberOfHandsets, UPSPowerOutLets, UPSSerialPort, UPSUSBPort " & _
    "FROM [Assetdetails] WHERE AssetID = " & Me.AssetID & ";"


    DBEngine(0)(0).Execute strSql, dbFailOnError


    Else
    MsgBox "Main record duplicated, but there were no related records."
    End If
    'Display the new duplicate.
    Me.Bookmark = .LastModified
    End With
    End If
    Exit_Handler:
    Exit Sub


    Err_Handler:
    MsgBox "Error " & Err.Number & " - " & Err.Description, , "cmdDupe_Click"
    Resume Exit_Handler
    Else
    End If
    On Error GoTo 0
    Exit Sub
    'Command75_Click_Error:
    'MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Command75_Click of VBA Document Form_EditAsset"
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try this debugging technique:

    http://www.baldyweb.com/ImmediateWindow.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi pbaldy

    many thanks for the link, will take a look and see if I can get my head around it.
    Steve

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problem Steve. It's a very common method of debugging SQL in code. The tip to copy the finished SQL into a new query is relevant, as it may point out misspelled fields or something similar. The error is telling you there are 2 things Access can't resolve.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi Pbaldy

    that's great many thanks again for the link.
    steve

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help! You found the cause of the error?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    yeah, I had miss spelt two field names
    can't believe I had missed that, been looking at it for hours lol

    mate I can't thank you enough for your help

    steve

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

Similar Threads

  1. Run-time error '3061'
    By TheLazyEngineer in forum Programming
    Replies: 1
    Last Post: 03-04-2015, 11:17 AM
  2. Run time error 3061
    By beaurou in forum Modules
    Replies: 18
    Last Post: 02-23-2015, 11:54 AM
  3. Run-Time Error 3061
    By GraeagleBill in forum Programming
    Replies: 2
    Last Post: 09-23-2013, 06:46 AM
  4. Run-time error 3061
    By boywonder in forum Programming
    Replies: 1
    Last Post: 07-20-2011, 06:14 AM
  5. Run-Time error 3061
    By boywonder in forum Programming
    Replies: 12
    Last Post: 05-24-2011, 10:15 AM

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