Link to home
Start Free TrialLog in
Avatar of jimwaite
jimwaite

asked on

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?
ASKER CERTIFIED SOLUTION
Avatar of hes
hes
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?)