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: -
If rstSPC.[Ni_Au_Nickel_Thickness_Avg] > SPCAve + 2 * SPCSigma Then TwoOfThreeP = TwoOfThreeP + 1
-
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! -
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 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: -
If rstSPC.[Ni_Au_Nickel_Thickness_Avg] > SPCAve + 2 * SPCSigma Then TwoOfThreeP = TwoOfThreeP + 1
-
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! -
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 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...
|
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...
|
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
|
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...
|
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
| |
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.
|
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
|
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
|
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...
|
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,...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
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...
| |