?
Solved

VBA Error  3265  Item not found in this collection.

Posted on 2011-03-09
12
Medium Priority
?
1,221 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Accepted Solution

by:
derekkromm earned 2000 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 2000 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 2000 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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

764 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