473,671 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Item not found in collection error

5 New Member
This code is supposed to take the last three records entered into the query "Ni-Au-CooperSubformQu ery" and place them in the table MyTable. After placing the three records in the table it should analyze them.

For some reason I am getting the "item not found in collection" error when I execute this code. It pertains to my line:
Expand|Select|Wrap|Line Numbers
  1. If rstSPC.[Ni_Au_Nickel_Thickness_Avg] > SPCAve + 2 * SPCSigma Then TwoOfThreeP = TwoOfThreeP + 1
  2.  
For some reason the field [Ni_Au_Nickel_Th ickness_Avg] is not being recognized as part of the recordset I am creating. Any help would be greatly appreciated!

Expand|Select|Wrap|Line Numbers
  1.     Dim dbSPC As Object
  2.     Dim rstSPC As Object
  3.     Dim strSQL As String
  4.     Dim DQC As String
  5.     Dim LoopCnt As String
  6.  
  7. If Me.[cboPartNumber] = "156882-001" Then
  8.     SPCAve = DLookup("[Ni-Au-CooperNiAve]", "Ni-Au-Production Log", "[ID]=" & DMax("[ID]", "Ni-Au-Production Log"))
  9.     SPCSigma = DLookup("[Ni-Au-CooperNiSigma]", "Ni-Au-Production Log", "[ID]=" & DMax("[ID]", "Ni-Au-Production Log"))
  10.     Warning = "Nickel-Gold Cooper Nickel Thickness Out of Control.  SPC rule: 2 out of 3 consecutive points all appear above two standard deviations from the center line."
  11.     WarningTitle = "Ni/Au Line Cooper Nickel Thickness Out of Control"
  12.     PartQuery = "Ni-Au-CooperSubformQuery"
  13. End If
  14.  
  15.  
  16. 'Set up for quote characters & comma to be used in String
  17. DQC = """, """
  18. 'run a delete query to clear table
  19. DoCmd.RunSQL "delete mytable.* from MyTable"
  20. ''''SET dbSPC EQUAL TO CURRENT DATABASE
  21.     Set dbSPC = CurrentDb
  22. ''''OPEN THE QUERY FOR THE SPECIFIC PART NUMBER
  23.     Set rstSPC = dbSPC.OpenRecordset(PartQuery)
  24. 'Set your initial value for loop counter
  25. LoopCnt = 1
  26. '''''2 of 3 CONSECUTIVE POINTS ABOVE 2 SIGMA FROM CENTER LINE
  27.     rstSPC.MoveLast
  28. For i = 1 To 3
  29.     If rstSPC.[Ni_Au_Nickel_Thickness_Avg] > SPCAve + 2 * SPCSigma Then TwoOfThreeP = TwoOfThreeP + 1
  30.     strSQL = "insert into MyTable(LoopCount,NickelThicknessAve,Ave,Sigma,TwoofThreeP) select """ & _
  31.            LoopCnt & DQC & rstSPC.[Ni_Au_Nickel_Thickness_Avg] & _
  32.             DQC & SPCAve & DQC & SPCSigma & DQC & TwoOfThreeP & """"
  33. 'Last """" is for your last closing quote
  34.  
  35. 'execute your SQL insert query constructed in strSQL
  36. DoCmd.RunSQL strSQL
  37. 'Increment your loop counter
  38. LoopCnt = LoopCnt + 1
  39.     rstSPC.MovePrevious
  40. Next i
  41. If TwoOfThreeP > 1 Then MsgBox Warning, vbExclamation, WarningTitle
  42.     Me.Point1.Caption = TwoOfThreeP
  43.     DoCmd.GoToRecord , , acLast
  44.  
Dec 1 '06 #1
1 3170
sashi
1,754 Recognized Expert Top Contributor
This code is supposed to take the last three records entered into the query "Ni-Au-CooperSubformQu ery" and place them in the table MyTable. After placing the three records in the table it should analyze them.

For some reason I am getting the "item not found in collection" error when I execute this code. It pertains to my line:
Expand|Select|Wrap|Line Numbers
  1. If rstSPC.[Ni_Au_Nickel_Thickness_Avg] > SPCAve + 2 * SPCSigma Then TwoOfThreeP = TwoOfThreeP + 1
  2.  
For some reason the field [Ni_Au_Nickel_Th ickness_Avg] is not being recognized as part of the recordset I am creating. Any help would be greatly appreciated!

Expand|Select|Wrap|Line Numbers
  1.     Dim dbSPC As Object
  2.     Dim rstSPC As Object
  3.     Dim strSQL As String
  4.     Dim DQC As String
  5.     Dim LoopCnt As String
  6.  
  7. If Me.[cboPartNumber] = "156882-001" Then
  8.     SPCAve = DLookup("[Ni-Au-CooperNiAve]", "Ni-Au-Production Log", "[ID]=" & DMax("[ID]", "Ni-Au-Production Log"))
  9.     SPCSigma = DLookup("[Ni-Au-CooperNiSigma]", "Ni-Au-Production Log", "[ID]=" & DMax("[ID]", "Ni-Au-Production Log"))
  10.     Warning = "Nickel-Gold Cooper Nickel Thickness Out of Control.  SPC rule: 2 out of 3 consecutive points all appear above two standard deviations from the center line."
  11.     WarningTitle = "Ni/Au Line Cooper Nickel Thickness Out of Control"
  12.     PartQuery = "Ni-Au-CooperSubformQuery"
  13. End If
  14.  
  15.  
  16. 'Set up for quote characters & comma to be used in String
  17. DQC = """, """
  18. 'run a delete query to clear table
  19. DoCmd.RunSQL "delete mytable.* from MyTable"
  20. ''''SET dbSPC EQUAL TO CURRENT DATABASE
  21.     Set dbSPC = CurrentDb
  22. ''''OPEN THE QUERY FOR THE SPECIFIC PART NUMBER
  23.     Set rstSPC = dbSPC.OpenRecordset(PartQuery)
  24. 'Set your initial value for loop counter
  25. LoopCnt = 1
  26. '''''2 of 3 CONSECUTIVE POINTS ABOVE 2 SIGMA FROM CENTER LINE
  27.     rstSPC.MoveLast
  28. For i = 1 To 3
  29.     If rstSPC.[Ni_Au_Nickel_Thickness_Avg] > SPCAve + 2 * SPCSigma Then TwoOfThreeP = TwoOfThreeP + 1
  30.     strSQL = "insert into MyTable(LoopCount,NickelThicknessAve,Ave,Sigma,TwoofThreeP) select """ & _
  31.            LoopCnt & DQC & rstSPC.[Ni_Au_Nickel_Thickness_Avg] & _
  32.             DQC & SPCAve & DQC & SPCSigma & DQC & TwoOfThreeP & """"
  33. 'Last """" is for your last closing quote
  34.  
  35. 'execute your SQL insert query constructed in strSQL
  36. DoCmd.RunSQL strSQL
  37. 'Increment your loop counter
  38. LoopCnt = LoopCnt + 1
  39.     rstSPC.MovePrevious
  40. Next i
  41. If TwoOfThreeP > 1 Then MsgBox Warning, vbExclamation, WarningTitle
  42.     Me.Point1.Caption = TwoOfThreeP
  43.     DoCmd.GoToRecord , , acLast
  44.  

Hi there,

Error 3265. "Item not found in this collection" generally means the the field name you are referencing in you SQL statement doesn't exist in the table. Check to make sure you spelled the field name correctly.Good luck & Take care.
Dec 2 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
22805
by: CJM | last post by:
I'm running a stored procedure that inserts a record into a table then returns the Identity field value. I've done this kind of thing plenty of times in the past, but I'm obviously doing something wrong this time.. I've tested the Stored Proc in QA and it works fine. The SQL code runs OK in ASP (iAffected = 1 which shows the record is inserted), but when I try to query the resulting recordset, I get an error: "Item cannot be found in...
2
3972
by: RBohannon | last post by:
I had some help on this one earlier, but I'm still having a bit of trouble. I'm sure it's something simple that I just don't know. I'm using Access2000. I have one table with employee salary information. I need to calculate the bi-weekly gross pay (BWG) for each employee. The BWG is slightly different for leap years. As the BWG will have to be adjusted at the beginning and end of every leap year, I want to be able to update all...
9
8011
by: Gerald Lightsey | last post by:
I am doing some work that involves automating MS MapPoint 2002. The object model is documented in the context of Visual Basic 6.0. A typical example follows. 'Output first result of find search Set objFindResults = objApp.ActiveMap.FindAddressResults("One Microsoft Way", "Redmond", , "WA", , geoCountryUnitedStates) MsgBox "The first item in the find list is: " _ + objFindResults.Item(1).Name
18
4730
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the class where only the "searched" property has a value. I expected to get the index into the arraylist where I could then get the entire class instance. However, the 'indexof' is never calling my overloaded, overrides Equals method. Here is the...
2
3087
by: jmhmaine | last post by:
I've created a lookup class for a windows form application and I'm stuck on how on using the collection object. The process is simple, if the item is in the collection then return that object, if the item is not in the collection then create the item from a value in the database, then return it. Here is the code: Imports System.Data.SqlClient Public Class lookup
3
5533
by: snesbit | last post by:
I have a structure called SearchAreaListItem. The structure has some properties. The application implements this as a collection.generic.list(of SearchAreaListItem) I load the collection up item at a time stuffing values into the item then adding the item to the collection.
2
1696
by: indhu | last post by:
Hi its not working, i want only distinct record. here its repeated records coming. accdb = "SELECT DISTINCT sequence FROM scene WHERE sceneid = '" & myquery & "' " and when i select the first record in combo it says run time error: item cannot be found in teh collection corresponding to the requested name or ordinal. but not for second records
1
3919
by: wassimdaccache | last post by:
Hello Please help me I working on database using access 2003 I'm writing into a save bottom on a form this code to insert some of my value on another table ...no relationship between them If (CustomerID <> "") Then Dim stcriteria As String stcriteria = "= " & Dim myrs As Recordset
5
2502
by: MartyC | last post by:
When using the inbuilt Perfomance Analyser and selecting 'Cuurent Database' and 'Relationships' I receive an error message 'Item not found in this collection'. I have trawled through the relationships and they appear fine. Not sure if this is related but the Database splitter fails with the error message 'Subscript out of Range'. The tables are split from the main database as a _be.mdb but the links are not formed and the actual tables...
0
8393
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8917
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8821
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8670
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7437
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6229
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4407
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2812
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1809
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.