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