Run-time error '3251'

ebasta

Registered User.
Local time
Today, 07:50
Joined
Sep 2, 2004
Messages
33
hi,

I've a problem with this little code, I can't understand:

Option Compare Database

Dim numeriSchede As Variant
Dim DbCurr As DAO.Database
Dim tabella As DAO.Recordset

Private Sub Delete_Click()
Dim stringa As String

Set DbCurr = CurrentDb
Set tabella = DbCurr.OpenRecordset("Scheda Inserimento")

For Each numeriSchede In Scheda.ItemsSelected
stringa = Str(Scheda.ItemData(numeriSchede))
tabella.FindFirst "Numero Scheda = " & stringa
tabella.Delete
Next

Set DbCurr = Nothing
Set tabella = Nothing

End Sub


When a run this code it says:
run-time error '3251'
:confused: :confused: :confused: :confused:
 
Hi,

Suggest you change

tabella.FindFirst "Numero Scheda = " & stringa

to


tabella.FindFirst "Numero Scheda = '" & stringa & "'"
 
Already done :(

What I would like to do is:
- take the selected items in my listbox

- delete the correpondent records of another table
 
ebasta said:
hi,

I've a problem with this little code, I can't understand:

Option Compare Database

Dim numeriSchede As Variant
Dim DbCurr As DAO.Database
Dim tabella As DAO.Recordset

Private Sub Delete_Click()
Dim stringa As String

Set DbCurr = CurrentDb
Set tabella = DbCurr.OpenRecordset("Scheda Inserimento")

For Each numeriSchede In Scheda.ItemsSelected
stringa = Str(Scheda.ItemData(numeriSchede))
tabella.FindFirst "Numero Scheda = " & stringa
tabella.Delete
Next

Set DbCurr = Nothing
Set tabella = Nothing

End Sub


When a run this code it says:
run-time error '3251'
:confused: :confused: :confused: :confused:


Code:
For Each numeriSchede In Scheda.ItemsSelected
   strSelectedList = strSelectedList & iif(len(strselectedlist)>0,",","") & "'" & Str(Scheda.ItemData(numeriSchede)) & "'"
Next


strSql="Delete * from [Scheda Inserimento] where [Numero Scheda] in [color=green]([/color]" & strSelectedList [color=green]& ")"[/color]
currentdb.execute strSql

You could try the above. also if you have a unique ID in the combo list, then get rid of the single quotes and put that in instead (amended the field name etc as required


Vince
 

Users who are viewing this thread

Back
Top Bottom