C
CJ
Hi Groupies:
I am using the SelectRecords listbox example from Sandra Daigle in an Access
2007 database.
Everything is working fine except when I go to remove a selected item from
the right hand box to the left hand box.
I get the error "Run time error 3061" "Too few parameters. Expected 1".
I have tried to everything the same because I had no idea how to do this
myself.
The only thing that I see as being different is where she has ClassID
(autonumber) I have strSKUNumber (text size 10)
My code is below:
Private Sub cmdRemoveOne_Click()
Dim strSQL As String
Dim strwhere As String
Dim db As DAO.Database
Dim varItem As Variant
For Each varItem In Me.lstTruckInventory.ItemsSelected
strwhere = strwhere & "strSKUNumber= " &
Me.lstTruckInventory.ItemData(varItem) & " Or "
' strwhere = strwhere & "ClassID= " & Me.lstSelected.ItemData(varItem) & "
Or " <code that Sandra had>
Next varItem
strwhere = Left(strwhere, Len(strwhere) - 4)
strSQL = "Delete * from tblTruckItems where lngTruckID=" & Me.lngTruckID & "
AND (" & strwhere & ");"
Set db = CurrentDb
db.Execute strSQL
Me.lstShopInventory.Requery
Me.lstTruckInventory.Requery
Set db = Nothing
End Sub
Can somebody please help me understand and fix the problem.
I am using the SelectRecords listbox example from Sandra Daigle in an Access
2007 database.
Everything is working fine except when I go to remove a selected item from
the right hand box to the left hand box.
I get the error "Run time error 3061" "Too few parameters. Expected 1".
I have tried to everything the same because I had no idea how to do this
myself.
The only thing that I see as being different is where she has ClassID
(autonumber) I have strSKUNumber (text size 10)
My code is below:
Private Sub cmdRemoveOne_Click()
Dim strSQL As String
Dim strwhere As String
Dim db As DAO.Database
Dim varItem As Variant
For Each varItem In Me.lstTruckInventory.ItemsSelected
strwhere = strwhere & "strSKUNumber= " &
Me.lstTruckInventory.ItemData(varItem) & " Or "
' strwhere = strwhere & "ClassID= " & Me.lstSelected.ItemData(varItem) & "
Or " <code that Sandra had>
Next varItem
strwhere = Left(strwhere, Len(strwhere) - 4)
strSQL = "Delete * from tblTruckItems where lngTruckID=" & Me.lngTruckID & "
AND (" & strwhere & ");"
Set db = CurrentDb
db.Execute strSQL
Me.lstShopInventory.Requery
Me.lstTruckInventory.Requery
Set db = Nothing
End Sub
Can somebody please help me understand and fix the problem.