VB Run Time Error 3265 "item not found in this collection"

Hello people.

I am receiving the VB  run time error 3265 "item not found in this collection"

This is my code: can't see anything unusual:

--------------------------------------------------------------------------------------------------

    Dim CarMake As String
    Dim CarModel As String
    Dim CarMileage As Long
    Dim CarEngine As Long
    Dim CarChassis As Long
    Dim CarColour As String
    Dim CarNoServices As Integer
    Dim CarServiceRefs(5) As Integer
       
    CarMake = Form1.Text1.Text
    CarModel = Form1.Text2.Text
    CarMileage = Form1.Text3.Text
    CarEngine = Form1.Text4.Text
    CarChassis = Form1.Text5.Text
    CarColour = Form1.Text6.Text
    CarNoServices = Form1.Text7.Text
    CarServiceRefs(1) = Form1.Text8.Text
    CarServiceRefs(2) = Form1.Text9.Text
    CarServiceRefs(3) = Form1.Text10.Text
    CarServiceRefs(4) = Form1.Text11.Text
    CarServiceRefs(5) = Form1.Text12.Text
   
    dclExample.Recordset.AddNew
    dclExample.Recordset!Make = CarMake
    dclExample.Recordset!Model = CarModel
    dclExample.Recordset!Mileage = CarMileage
    dclExample.Recordset!EngineSize = CarEngine
    dclExample.Recordset!ChassisNumber = CarChassis
    dclExample.Recordset!Colour = CarColour
    dclExample.Recordset!NumberOfServices = CarNoServices
    dclExample.Recordset!ServiceReferenceNumber(1) = CarServiceRefs(1)
    dclExample.Recordset!ServiceReferenceNumber(2) = CarServiceRefs(2)
    dclExample.Recordset!ServiceReferenceNumber(3) = CarServiceRefs(3)
    dclExample.Recordset!ServiceReferenceNumber(4) = CarServiceRefs(4)
    dclExample.Recordset!ServiceReferenceNumber(5) = CarServiceRefs(5)

--------------------------------------------------------------------------------------------------

Any ideas?
jimwaiteAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hesCommented:
Dim CarServiceRefs(5) As Integer
This will give you array elements 0-4 unless you have changed the default array boundry of 0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jmundsackCommented:
This is not good syntax:

    dclExample.Recordset!ServiceReferenceNumber(1) = CarServiceRefs(1)
    dclExample.Recordset!ServiceReferenceNumber(2) = CarServiceRefs(2)
    dclExample.Recordset!ServiceReferenceNumber(3) = CarServiceRefs(3)
    dclExample.Recordset!ServiceReferenceNumber(4) = CarServiceRefs(4)
    dclExample.Recordset!ServiceReferenceNumber(5) = CarServiceRefs(5)

My guess is it's choking on the parentheses.  The ! operator on the recordset is really a shorthand for saying...

    dclExample.Recordset.Fields("ServiceReferenceNumber(1)").Value
    'etc.

This would only be valid if there were actually a field named ServiceReferenceNumber(1), including the parentheses.  I'm guessing there isn't actually a field named ServiceReferenceNumber(1).

What is the actual field name?  (Or am I wrong?)

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.