too few parameters expected 1.

goldstar19821982

Registered User.
Local time
Today, 14:53
Joined
Feb 17, 2008
Messages
78
I currently have a listbox in one of my forms, when selected and delete is pressed i wish to delete this item from the list .
This is what i have been trying

Code: ( vb )
If MsgBox("Would you like to delete?", vbYesNo, "Confirmation") = vbYes Then
Set rstDelete = CurrentDb.OpenRecordset("SELECT * FROM tblorderlist WHERE productID = " & 1stlistbox)
rstDelete.Delete
rstDelete.Close
End if

an error message is being displayed suggesting
too few parameters expected 1.

Would anyone know what that means.?
 
It means that your SQL statement contains an identifier that doesn't exist. Maybe tblorderlist doesn't exist, or doesn't contain a field called productID.
 
When you get into debug mode when you get the error, what is the value of 1stlistbox?

As an alternative to the recordset, I'd simply have:

CurrentDb.Execute "DELETE * FROM tblorderlist WHERE productID = " & 1stlistbox
 
True. Or just ...
Code:
DELETE FROM tblorderlist...
 
There's no parameter because 1stlistbox is a text field. (99% sure I'm guessing that one right.) Make it this:

Set rstDelete = CurrentDb.OpenRecordset("SELECT * FROM tblorderlist WHERE productID = '" & 1stlistbox & "'")

Changes are in red.
 
Thanks. this works a charm.
But one thing related to this is, when i am selecting the item i want to edit, i am double clicking on the item which would bring the line selected to the orderline to be edited.
If the first order i placed had say itemno1
And the second order placed has itemno1 too
If i want to edit the second item i double click on it, but what is happening it is bringing the first item within the tblline.
For each item the unique idenfier is itemno. but various orders can have the same item. i have an itemhireno which is unqiue for each order, but im not sure how to produce the coding for this.
This is what i have got so far

Set rstedit= CurrentDb.OpenRecordset("tblline")
 

Users who are viewing this thread

Back
Top Bottom