G
Guest
Hello,
I have a VBA code for clicking a button called "Duplicate Record" and it is
as follows:
Private Sub command17_click()
On Error GoTo Err_Command17_Click
Dim NewAssemblyPartID As String
'Method 3: use DAO Object and two append queries
Dim strSQL As String
Dim db As DAO.Database
Dim qd As DAO.Querydef
Set db = CurrentDb
' clone the AssemblyPart table first
strSQL = "INSERT INTO [AssemblyParts] Select
AssemblyPartID,Name,Description,InputDate,CompleteBy,Notes,Lock FROM
[AssemblyParts]" & " WHERE [AssemblyPartID] = " & Me![AssemblyPartID] & ";"
' Create an unnamed/unstored Query to run
Set qd = db.CreateQuerydef("", strSQL)
' and run it; any errors will jump to err_command17_click
qd.Execute dbFailOnError
Set qd = Nothing
Exit_Command17_Click:
Exit Sub
Err_Command17_Click:
MsgBox Err.Description
Resume Exit_Command17_Click
End Sub
I always get error message when I click the button in form view, "Too few
parametres. Expect 1." And I am not very knowledgable on VBA coding and I am
still in the process of learning. However this error drove me crazy. I have
no clues which line has too few parametres... Any advice will be appreciated!
Thanks for your time!!!
I have a VBA code for clicking a button called "Duplicate Record" and it is
as follows:
Private Sub command17_click()
On Error GoTo Err_Command17_Click
Dim NewAssemblyPartID As String
'Method 3: use DAO Object and two append queries
Dim strSQL As String
Dim db As DAO.Database
Dim qd As DAO.Querydef
Set db = CurrentDb
' clone the AssemblyPart table first
strSQL = "INSERT INTO [AssemblyParts] Select
AssemblyPartID,Name,Description,InputDate,CompleteBy,Notes,Lock FROM
[AssemblyParts]" & " WHERE [AssemblyPartID] = " & Me![AssemblyPartID] & ";"
' Create an unnamed/unstored Query to run
Set qd = db.CreateQuerydef("", strSQL)
' and run it; any errors will jump to err_command17_click
qd.Execute dbFailOnError
Set qd = Nothing
Exit_Command17_Click:
Exit Sub
Err_Command17_Click:
MsgBox Err.Description
Resume Exit_Command17_Click
End Sub
I always get error message when I click the button in form view, "Too few
parametres. Expect 1." And I am not very knowledgable on VBA coding and I am
still in the process of learning. However this error drove me crazy. I have
no clues which line has too few parametres... Any advice will be appreciated!
Thanks for your time!!!