Error 3061 - Too Few Parameters

J0eydak!ng

New member
Local time
Today, 03:29
Joined
Aug 1, 2013
Messages
6
Hi,

I'm a beginner to all this.

I have a form to add and delete (through buttons present on the form) into a table called City. The City table has 2 fields called 'cityname' and 'country'. I also have a subform which displays the contents of the table so when I add or delete from the table I can view the changes in the subform.

The aim is that the user deletes a record from the subform and the db deletes the record depending on the value in the cityname field (which is also the pk to the table)

I can add with no problem, however when I delete I click on the record from the subform which I wish to delete and press the delete button I get error 3061. Too few Parameters.

The code lies below to the delete button:

Code:
Private Sub btnDelete_Click()
    'Check Exisisting Selected Record
    If Not (Me.subCityfrm.Form.Recordset.EOF Or Me.subCityfrm.Form.Recordset.BOF) Then
        'Confirm Delete
        If MsgBox("Are you sure you want to delete this City?", vbYesNo) = vbYes Then
        'Delete Now
        CurrentDb.Execute "Delete From City Where cityname=" & Me.subCityfrm.Form![cityname]
        'requery Database
        Me.subCityfrm.Requery
        End If
    End If
End Sub

Please HELPPP!!!!

Thanks In advance.

Regards,

Joe
 
Thanks Paul,

It worked flawlessly.

For future reference, (and since I'm a beginner at this) Could you explain the difference between the code I provided and the code you provided.

Is it because the parameter to be selected is text ?

Regards,

Joseph
 

Users who are viewing this thread

Back
Top Bottom