Run-time Error '2480'

R

RobUCSD

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,
 
R

RobUCSD

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


Top