Solved

VBA Error  3265  Item not found in this collection.

Posted on 2011-03-09
12
1,211 Views
Last Modified: 2012-05-11
I have a stored procedure that requires a date parameter.  It is called from from within an access function.  The results from the Immediate window return:
VBA Error
 3265
Item not found in this collection.

I am assuming that means there are no records found.  In order to eliminate complexities, I have tested the stored procedure form the SQL Server query editor and I am unsure what the correct date format required.  Here is the stored procedure or the editor that I am executing from:

USE [PSEOC IBIX Import]
GO

DECLARE      @return_value int

EXEC      @return_value = [dbo].[Get_IBIX_Success_Totals_By_Date]
            @ActualCostDate = '3/2/2011 12:00:00 AM'

SELECT      'Return Value' = @return_value

GO
0
Comment
Question by:psueoc
  • 6
  • 5
12 Comments
 
LVL 6

Expert Comment

by:TMWSIY
ID: 35083147
'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.

0
 
LVL 15

Expert Comment

by:derekkromm
ID: 35083149
double check the variable you're passing in from access

if you're passing "2011-1-1", it needs to be wrapped in single quotes to pass it as a string/date rather than an integer
0
 

Author Comment

by:psueoc
ID: 35083290
?ParamSPT2('2011-07-01')  This states compiler expected expression

?ParamSPT2("2011-07-01")
2011-07-01
VBA Error
 3265
Item not found in this collection.


?ParamSPT2(2011-07-01)
2003
VBA Error
 3265
Item not found in this collection.
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 15

Accepted Solution

by:
derekkromm earned 500 total points
ID: 35083373
can you try it w/ this line commented out, to verify which line of code is causing the error?

 Debug.Print MyRS!attribute_id, MyRS!attribute_name, MyRS!attribute_value
0
 

Author Comment

by:psueoc
ID: 35083446
?ParamSPT2("2011-07-01")
2011-07-01
0
 
LVL 15

Assisted Solution

by:derekkromm
derekkromm earned 500 total points
ID: 35083498
so no error?

it appears it is unable to find at least one of those field names in the recordset (attribute_id, attribute_name, attribute_value)

can you show a sample output of the stored procedure execution from sql server?
0
 

Author Comment

by:psueoc
ID: 35083790
This is not the output but it may help.  The output is null.


USE [PSEOC IBIX Import]
GO
/****** Object:  StoredProcedure [dbo].[Get_IBIX_Success_Totals_By_Date]    Script Date: 03/09/2011 10:17:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:            
-- Create date: 6/4/08
-- Description:      Returns success row count and cost for a given actual cost date
-- =============================================
ALTER PROCEDURE [dbo].[Get_IBIS_Success_Totals_By_Date]
      @ActualCostDate                        datetime
AS
BEGIN
      -- SET NOCOUNT ON added to prevent extra result sets from
      -- interfering with SELECT statements.
      SET NOCOUNT ON;

      select sum(SuccessRowCount) as 'Rows Imported Successfully', sum(successactualcosttotal) as 'Total Actual Cost Imported Successfully'
      from IBIX_Import_Batch
      where ActualCostDate = @ActualCostDate

END



0
 
LVL 15

Assisted Solution

by:derekkromm
derekkromm earned 500 total points
ID: 35083858
first, this:

Debug.Print MyRS!attribute_id, MyRS!attribute_name, MyRS!attribute_value

Open in new window


is going to fail because there aren't any attributes returned that have those names. you need to just remove that (part of a previous program/test?) or change it to the actual attributes

second, if you run this in query analyzer:

[dbo].[Get_IBIS_Success_Totals_By_Date] '2011-01-01'

Open in new window


do you get a row back? and if so, does it work for that date in your code?

if not, does this work:
select sum(SuccessRowCount) as 'Rows Imported Successfully', sum(successactualcosttotal) as 'Total Actual Cost Imported Successfully' 
      from IBIX_Import_Batch 
      where ActualCostDate = '2011-01-01'

Open in new window


if still nulls, it probably means that date isn't in the table. find a date that works using:

select distinct ActualCostDate from IBIX_Import_Batch order by ActualCostDate

Open in new window


pick a date from that list and try the statements at the beginning of the post w/ it
0
 

Author Comment

by:psueoc
ID: 35084654
We're close.  I am able to "pick a date from that list and try the statements at the beginning of the post w/ it ."  But when I try it in the access Immediate window I still receive:

2011-03-02
VBA Error
 3265
Item not found in this collection.

or nothing when Debug.Print MyRS!attribute_id, MyRS!attribute_name, MyRS!attribute_value is commented out.
0
 
LVL 15

Assisted Solution

by:derekkromm
derekkromm earned 500 total points
ID: 35084702
replace that debug.print with this:

Debug.Print MyRS![Rows Imported Successfully], MyRS![Total Actual Cost Imported Successfully]

Open in new window


0
 

Author Comment

by:psueoc
ID: 35084776
Awesome!  That works.  Thanks derekkromm for your effort with this issue!  So I should be able to hook that to an Access form, button event and return the results?
0
 
LVL 15

Expert Comment

by:derekkromm
ID: 35084799
I believe so
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

726 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