Run-time Error '2480'

G

Guest

With the code below I'm getting; "Run-time Error '2480' you reffered to a
property by a numeric argument that isn't one of the property numbers in the
collection."

Debug.Print gave me this; db nothing, strSql nothing, VarItem Emptly.

I think I'm doing something wrong in the INSERT INTO tblRNnotes
(fldRNnotesLUno) part of the code.

Pls help if you can, thanks, Rob
*******************************************************
Private Sub lstRNnotesLU_DblClick(Cancel As Integer)
Dim db As DAO.Database
Dim strSQL As String
Dim varItm As Variant

Set db = CurrentDb()
With Forms!frmRNnotes!lstRNnotesLU
For Each varItm In .ItemsSelected
strSQL = "INSERT INTO tblRNnotes (fldRNnotesLUno) " & _
"VALUES('" & .ItemsSelected(varItm)
db.Execute strSQL, dbFailOnError
Next varItm
End With

Debug.Print
End Sub
**********************************************************
 
G

George Nicholson

Use the ItemData property and supply the closing single-quote. Try:
"VALUES('" & .ItemData(varItm) & "'"

HTH,
 
G

Guest

Thanks George for your response. Now I'm getting a syntax error on
db.Execute strSQL, dbFailOnError. Any ideas.

thanks very much for your help. I need it. Rob
*****************************************************
Dim db As DAO.Database
Dim strSQL As String
Dim varItm As Variant

Set db = CurrentDb()
With Forms!frmRNnotes!lstRNnotesLU
For Each varItm In .ItemsSelected
strSQL = "INSERT INTO tblRNnotes (fldRNnotesLUno) " & _
"VALUES('" & .ItemData(varItm) & "'"
db.Execute strSQL, dbFailOnError
Next varItm
End With
***************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Syntax error 14
Stuck, Need Help w/ Code 3
Getting no where 1
Need help w/ syntax! 3
Erro 3201 3
Code Help 10
combo box - Help! 2
saving listbox choices to a table 2

Top