Solved

Run Time Error 3265 "Item not found in this collection"

Posted on 2014-02-10
11
4,838 Views
Last Modified: 2014-02-11
I am trying to pass some data from one field to the next in the same table. I have this code that I am using. It has been great for four years. However, today I added a new field.
The new field is listed as #9 Sort (Yes/No)

When I run the code I get a "Run Time Error 3265" Item not found in this collection".
However, when I hit the debugger it goes to "qdTMMK.Parameters(10) = Me.DateCode".

Which has never given me a problem before

Sub CopyMultipleQrevalueTMMK_SelectByTagNumber()
Dim rsTMMK As DAO.Recordset
Dim qdTMMK As QueryDef
Dim reccountTMMK As Long
Dim copycountTMMK As Long
Dim msgStringTMMK As String
 
Set rsTMMK = Me.qQreValueTMMKVEHSubform.Form.RecordsetClone
If Not ((rsTMMK.BOF) And (rsTMMK.EOF)) Then
    rsTMMK.MoveLast
    reccountTMMK = rsTMMK.RecordCount
    Debug.Print reccountTMMK & " records in subform"
    rsTMMK.MoveFirst
     
    For ctr = 1 To rsTMMK.RecordCount
        If rsTMMK.Fields("Select") = True And rsTMMK("tagNumber") <> Me.TagNumber Then
            copycountTMMK = copycountTMMK + 1
            Debug.Print "*** Copying details to SKPI with Tagnumber " & rsTMMK.Fields("tagNumber")
            Set qdTMMK = CurrentDb.QueryDefs("qryUpdateQreValue_TagNumber")
            qdTMMK.Parameters("strTagNumber") = rsTMMK.Fields("tagNumber")
            'Fill in the form-based params
            qdTMMK.Parameters(1) = Me.ProblemDescription
            qdTMMK.Parameters(2) = Me.HowFound
            qdTMMK.Parameters(3) = Me.QREConfirmation
            qdTMMK.Parameters(4) = Me.InterimAction
            qdTMMK.Parameters(5) = Me.QualitAlertNumber
            qdTMMK.Parameters(6) = Me.SortedQuantity
            qdTMMK.Parameters(7) = Me.SortRejects
            qdTMMK.Parameters(8) = Me.[SortCompletion Date]
            qdTMMK.Parameters(9) = Me.[Sort (Yes/No)]
            qdTMMK.Parameters(10) = Me.DateCode
'            For x = 0 To qdTMMK.Parameters.Count - 1
'                Debug.Print x; qdTMMK.Parameters(x).Name & vbTab & vbTab & qdTMMK.Parameters(x).Value
'            Next
            qdTMMK.Execute
            Set qdTMMK = Nothing
        ElseIf rsTMMK("tagNumber") = Me.TagNumber Then
            Debug.Print "Skipping TagNumber" & rsTMMK("tagNumber") & " because it is the record being edited in the main form."
        End If
        rsTMMK.MoveNext
    Next
    msgStringTMMK = "Details were copied to " & copycountTMMK & " records."
Else
    msgStringTMMK = "No records in subform!"
End If
    MsgBox msgStringTMMK, vbOKOnly + vbInformation, "Copy to multiple SKPIs"
Set qdTMMK = Nothing
Set rsTMMK = Nothing
End Sub

Open in new window

0
Comment
Question by:ggodwin
  • 6
  • 3
11 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 150 total points
Comment Utility
<< #9 Sort >>

Is this the actual name of your field?

If so, try changing it to Sort9 -- or something that does not include spaces or special characters.

The # sign is bound to cause problems.
0
 

Author Comment

by:ggodwin
Comment Utility
Yes that is the name. Let me try to change it. But why wouldn't the error show on that line?
0
 

Author Comment

by:ggodwin
Comment Utility
I've done this...
Nothing different.
However, when I removed the #10 line "qdTMMK.Parameters(10) = Me.DateCode" the code seemed to work. However, the data did not populate in the new SortYesNo field.

When the (10) line is left then the original error code returns.

Here is my new code.

Sub CopyMultipleQrevalueTMMK_SelectByTagNumber()
Dim rsTMMK As DAO.Recordset
Dim qdTMMK As QueryDef
Dim reccountTMMK As Long
Dim copycountTMMK As Long
Dim msgStringTMMK As String
 
Set rsTMMK = Me.qQreValueTMMKVEHSubform.Form.RecordsetClone
If Not ((rsTMMK.BOF) And (rsTMMK.EOF)) Then
    rsTMMK.MoveLast
    reccountTMMK = rsTMMK.RecordCount
    Debug.Print reccountTMMK & " records in subform"
    rsTMMK.MoveFirst
     
    For ctr = 1 To rsTMMK.RecordCount
        If rsTMMK.Fields("Select") = True And rsTMMK("tagNumber") <> Me.TagNumber Then
            copycountTMMK = copycountTMMK + 1
            Debug.Print "*** Copying details to SKPI with Tagnumber " & rsTMMK.Fields("tagNumber")
            Set qdTMMK = CurrentDb.QueryDefs("qryUpdateQreValue_TagNumber")
            qdTMMK.Parameters("strTagNumber") = rsTMMK.Fields("tagNumber")
            'Fill in the form-based params
            qdTMMK.Parameters(1) = Me.ProblemDescription
            qdTMMK.Parameters(2) = Me.HowFound
            qdTMMK.Parameters(3) = Me.QREConfirmation
            qdTMMK.Parameters(4) = Me.InterimAction
            qdTMMK.Parameters(5) = Me.QualitAlertNumber
            qdTMMK.Parameters(6) = Me.SortedQuantity
            qdTMMK.Parameters(7) = Me.SortRejects
            qdTMMK.Parameters(8) = Me.[SortCompletion Date]
            qdTMMK.Parameters(9) = Me.SortYesNo
            qdTMMK.Parameters(10) = Me.DateCode
'            For x = 0 To qdTMMK.Parameters.Count - 1
'                Debug.Print x; qdTMMK.Parameters(x).Name & vbTab & vbTab & qdTMMK.Parameters(x).Value
'            Next
            qdTMMK.Execute
            Set qdTMMK = Nothing
        ElseIf rsTMMK("tagNumber") = Me.TagNumber Then
            Debug.Print "Skipping TagNumber" & rsTMMK("tagNumber") & " because it is the record being edited in the main form."
        End If
        rsTMMK.MoveNext
    Next
    msgStringTMMK = "Details were copied to " & copycountTMMK & " records."
Else
    msgStringTMMK = "No records in subform!"
End If
    MsgBox msgStringTMMK, vbOKOnly + vbInformation, "Copy to multiple SKPIs"
Set qdTMMK = Nothing
Set rsTMMK = Nothing
End Sub

Open in new window

0
 

Author Comment

by:ggodwin
Comment Utility
OK, When I remove that line of code it works.
However, there is one row where the data is populating the wrong fields.
0
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
I'd have to see your update query to give you any specific help.

however, most collections in Access are zero based, meaning that the first element is numbered ZERO, not 1.   There are exceptions to this rule, but if the parameter collection does start at zero (I can't remember offhand), that could explain unexpected fields if you are starting the count at 1 in your code.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 49

Expert Comment

by:Gustav Brock
Comment Utility
> However, when I removed the #10 line "qdTMMK.Parameters(10) = Me.DateCode"
> the code seemed to work.

Well, then that field is not present in your recordsource.

/gustav
0
 

Author Comment

by:ggodwin
Comment Utility
OK...
These errors seem to have resolved them selves.

Now everything is working except the data is not populating in one of the fields.

Should I start and entirely new question? or add it here?
0
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
Start a new question so that email are sent and the question is seen by others, and delete this one if nothing here helped.
0
 

Author Comment

by:ggodwin
Comment Utility
The responses did not apply. My database became corrupt and I did not have the same problem later.
0
 

Author Closing Comment

by:ggodwin
Comment Utility
This was not the exact fix to the problem. But, As I was checking this I came across and error in the update query. Once I made this recommended change in both the code and query the problem was resolved.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now