473,385 Members | 1,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Item not found in collection error

This code is supposed to take the last three records entered into the query "Ni-Au-CooperSubformQuery" 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_Thickness_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 3159
sashi
1,754 Expert 1GB
This code is supposed to take the last three records entered into the query "Ni-Au-CooperSubformQuery" 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_Thickness_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
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...
2
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...
9
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...
18
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...
2
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...
3
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 ...
2
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...
1
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 ...
5
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.