Solved

VBA Error  3265  Item not found in this collection.

Posted on 2011-03-09
12
1,206 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
 
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
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to convert sql code to access query 8 65
Help with SQL field formatting 3 20
Pivot Table for a join with partition by and over clause 7 27
Make query more efficient 1 16
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

914 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

20 Experts available now in Live!

Get 1:1 Help Now