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: -
If rstSPC.[Ni_Au_Nickel_Thickness_Avg] > SPCAve + 2 * SPCSigma Then TwoOfThreeP = TwoOfThreeP + 1
-
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! -
Dim dbSPC As Object
-
Dim rstSPC As Object
-
Dim strSQL As String
-
Dim DQC As String
-
Dim LoopCnt As String
-
-
If Me.[cboPartNumber] = "156882-001" Then
-
SPCAve = DLookup("[Ni-Au-CooperNiAve]", "Ni-Au-Production Log", "[ID]=" & DMax("[ID]", "Ni-Au-Production Log"))
-
SPCSigma = DLookup("[Ni-Au-CooperNiSigma]", "Ni-Au-Production Log", "[ID]=" & DMax("[ID]", "Ni-Au-Production Log"))
-
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."
-
WarningTitle = "Ni/Au Line Cooper Nickel Thickness Out of Control"
-
PartQuery = "Ni-Au-CooperSubformQuery"
-
End If
-
-
-
'Set up for quote characters & comma to be used in String
-
DQC = """, """
-
'run a delete query to clear table
-
DoCmd.RunSQL "delete mytable.* from MyTable"
-
''''SET dbSPC EQUAL TO CURRENT DATABASE
-
Set dbSPC = CurrentDb
-
''''OPEN THE QUERY FOR THE SPECIFIC PART NUMBER
-
Set rstSPC = dbSPC.OpenRecordset(PartQuery)
-
'Set your initial value for loop counter
-
LoopCnt = 1
-
'''''2 of 3 CONSECUTIVE POINTS ABOVE 2 SIGMA FROM CENTER LINE
-
rstSPC.MoveLast
-
For i = 1 To 3
-
If rstSPC.[Ni_Au_Nickel_Thickness_Avg] > SPCAve + 2 * SPCSigma Then TwoOfThreeP = TwoOfThreeP + 1
-
strSQL = "insert into MyTable(LoopCount,NickelThicknessAve,Ave,Sigma,TwoofThreeP) select """ & _
-
LoopCnt & DQC & rstSPC.[Ni_Au_Nickel_Thickness_Avg] & _
-
DQC & SPCAve & DQC & SPCSigma & DQC & TwoOfThreeP & """"
-
'Last """" is for your last closing quote
-
-
'execute your SQL insert query constructed in strSQL
-
DoCmd.RunSQL strSQL
-
'Increment your loop counter
-
LoopCnt = LoopCnt + 1
-
rstSPC.MovePrevious
-
Next i
-
If TwoOfThreeP > 1 Then MsgBox Warning, vbExclamation, WarningTitle
-
Me.Point1.Caption = TwoOfThreeP
-
DoCmd.GoToRecord , , acLast
-
1 3159
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: -
If rstSPC.[Ni_Au_Nickel_Thickness_Avg] > SPCAve + 2 * SPCSigma Then TwoOfThreeP = TwoOfThreeP + 1
-
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! -
Dim dbSPC As Object
-
Dim rstSPC As Object
-
Dim strSQL As String
-
Dim DQC As String
-
Dim LoopCnt As String
-
-
If Me.[cboPartNumber] = "156882-001" Then
-
SPCAve = DLookup("[Ni-Au-CooperNiAve]", "Ni-Au-Production Log", "[ID]=" & DMax("[ID]", "Ni-Au-Production Log"))
-
SPCSigma = DLookup("[Ni-Au-CooperNiSigma]", "Ni-Au-Production Log", "[ID]=" & DMax("[ID]", "Ni-Au-Production Log"))
-
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."
-
WarningTitle = "Ni/Au Line Cooper Nickel Thickness Out of Control"
-
PartQuery = "Ni-Au-CooperSubformQuery"
-
End If
-
-
-
'Set up for quote characters & comma to be used in String
-
DQC = """, """
-
'run a delete query to clear table
-
DoCmd.RunSQL "delete mytable.* from MyTable"
-
''''SET dbSPC EQUAL TO CURRENT DATABASE
-
Set dbSPC = CurrentDb
-
''''OPEN THE QUERY FOR THE SPECIFIC PART NUMBER
-
Set rstSPC = dbSPC.OpenRecordset(PartQuery)
-
'Set your initial value for loop counter
-
LoopCnt = 1
-
'''''2 of 3 CONSECUTIVE POINTS ABOVE 2 SIGMA FROM CENTER LINE
-
rstSPC.MoveLast
-
For i = 1 To 3
-
If rstSPC.[Ni_Au_Nickel_Thickness_Avg] > SPCAve + 2 * SPCSigma Then TwoOfThreeP = TwoOfThreeP + 1
-
strSQL = "insert into MyTable(LoopCount,NickelThicknessAve,Ave,Sigma,TwoofThreeP) select """ & _
-
LoopCnt & DQC & rstSPC.[Ni_Au_Nickel_Thickness_Avg] & _
-
DQC & SPCAve & DQC & SPCSigma & DQC & TwoOfThreeP & """"
-
'Last """" is for your last closing quote
-
-
'execute your SQL insert query constructed in strSQL
-
DoCmd.RunSQL strSQL
-
'Increment your loop counter
-
LoopCnt = LoopCnt + 1
-
rstSPC.MovePrevious
-
Next i
-
If TwoOfThreeP > 1 Then MsgBox Warning, vbExclamation, WarningTitle
-
Me.Point1.Caption = TwoOfThreeP
-
DoCmd.GoToRecord , , acLast
-
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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 ...
|
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...
|
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
...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
| |