Solved

Filter Error?

Posted on 2003-11-12
11
240 Views
Last Modified: 2010-05-01
code:
     Tbl_System.DB_Recs.Filter = "SysID=6"

Error:
     "Item cannot be found in the collection corresponding to the requested name or ordinal."

I have no idea what is wrong! Help!

   - Marc

Here is the SQL:
     SELECT SysID, SysData FROM Tbl_System
0
Comment
Question by:MarcGraff
[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
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 1

Author Comment

by:MarcGraff
ID: 9734041
Tbl_System.DB_Recs is a recordset.

   - Marc
0
 
LVL 4

Expert Comment

by:TomLaw1999
ID: 9734091
Needs to be something like this

Tbl_System.DB_Recs.Filter = "SysID = " & 6
0
 
LVL 1

Author Comment

by:MarcGraff
ID: 9734322
No diffrence. :(

   - Marc
0
Industry Leaders: 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 5

Expert Comment

by:rpai
ID: 9735113
Try this: -
Tbl_System.DB_Recs.Filter = "SysID = 6"

Should work!

0
 
LVL 5

Expert Comment

by:rpai
ID: 9735148
Oops.. did not realize that you were using the same exact code. Sorry!

I suppose you are using VB6.
How have you declared the Tbl_System.DB_Recs as recordset?

Doing this
Dim Tbl_System.DB_Recs  as ADODB.Recordset
is likely to yield an error.

Try
Dim TblSystem as ADODB.Recordset instead.

Hopefully the filter property of the recordset should work.



0
 
LVL 1

Author Comment

by:MarcGraff
ID: 9735189
Yeah, DB_Recs is in a class modual.

This class modual is defined as Tbl_System. Unfortunetly this class modual works elsewhere...

For example: Tbl_Exeptions.DB_Recs.Filter = "ID=2"                    'works fine

The problem must be elsewhere... I just can't find it.

   - Marc
0
 
LVL 5

Expert Comment

by:rpai
ID: 9735316
Please read this :- http://www.adopenstatic.com/faq/800a0cc1.asp
Might be of help.

0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 9736679
>>Tbl_System.DB_Recs is a recordset.

Is is a ADO recordset ?
0
 
LVL 39

Accepted Solution

by:
appari earned 500 total points
ID: 9736817
to make sure that recordset is using the same SQL as you are thinking, add this line and post the result printed in debug window here

debug. print Tbl_System.DB_Recs.Source
Tbl_System.DB_Recs.Filter = "SysID=6"
0
 
LVL 4

Expert Comment

by:TomLaw1999
ID: 9738154
Marc are you still having a problem. I believed that the error message was because you included the  = 6 bit within quotation marks i.e. "SysID=6" was not recognised but "SysID" should be.

If my original suggestion did not work i.e. Tbl_System.DB_Recs.Filter = "SysID = " & 6
 then try

Dim X as long
X=6
Tbl_System.DB_Recs.Filter = "SysID = " & X

Should'nt make any real difference but be especially careful about the positioning of the quotation marks and leave a space between the = sign and the last quotation mark.

 
0
 
LVL 1

Author Comment

by:MarcGraff
ID: 9740468
Hey! appari, your right!

I initialized it as:
SELECT SysID, SysData FROM Tbl_System

By using debug I found that the select statement has been changed! So I went back and found that I accidentally reinitialized it to another select statement. I have corrected the problem and it works great! Thanks so much!

   - Marc
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

752 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