Solved

VBA Error  3265  Item not found in this collection.

Posted on 2011-03-09
12
1,203 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
Comment Utility
'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
Comment Utility
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
Comment Utility
?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
 
LVL 15

Accepted Solution

by:
derekkromm earned 500 total points
Comment Utility
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
Comment Utility
?ParamSPT2("2011-07-01")
2011-07-01
0
 
LVL 15

Assisted Solution

by:derekkromm
derekkromm earned 500 total points
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:psueoc
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I believe so
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now