troubleshooting Question

Access 2003 VBA error when executing INSERT statement - "Too few Parameters. Expected 1".

Avatar of bluelangroup
bluelangroupFlag for United States of America asked on
Microsoft AccessSQL
5 Comments1 Solution464 ViewsLast Modified:
Hello,

In an Access 2003 database, I've created a button on a form that opens a subform in a popup window, linked to the parent form via the ClaimAutoID field (the underlying tables for the form and the subform are also linked via this field).  The code for this is as follows:

Private Sub AddNewNoteCmd_Click()
On Error GoTo Err_AddNewNoteCmd_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Add New Note"
    stLinkCriteria = "[ClaimAutoID] = " & Me.ClaimAutoID
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    DoCmd.GoToRecord , , acNewRec

Exit_AddNewNoteCmd_Click:
    Exit Sub

Err_AddNewNoteCmd_Click:
    MsgBox Err.Description
    Resume Exit_AddNewNoteCmd_Click
   
End Sub

The code that links the popped up subform to the parent form via the ClaimAutoID works fine, in that the records you see if you scroll through entries in the subform are only the records that are related to the current record on the parent form.  However, when you save a new record on this subform, it gets saved without any data in the ClaimAutoID field, so the new record that get saved are no longer linked to the current record in the parent form.  To deal with this I've created a "Save" button on the subform which is supposed to insert the value in the ClaimAutoID field from the current record on the parent form into the ClaimAutoID field for the current record being saved in the subform.  The ClaimAutoID field is not visible in the subform.  Here is the code:

Private Sub SaveNote_Click()
On Error GoTo Err_SaveNote_Click

    Dim strSQL As String

    strSQL = "INSERT Into tblClaims_Notes (ClaimAutoID) VALUES (Me.ClaimAutoID)"
   
    CurrentDb.Execute strSQL, dbFailOnError
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_SaveNote_Click:
    Exit Sub

Err_SaveNote_Click:
    MsgBox Err.Description
    Resume Exit_SaveNote_Click
   
End Sub


When I click on this save button, I get the error "Too few parameters. Expected 1".  Can someone please tell me what I'm doing wrong?  Any help is greatly appreciated.

Thank you.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros