Solved

Filter Error?

Posted on 2003-11-12
11
236 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
  • 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
 
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
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.

 
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 69

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

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

895 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

11 Experts available now in Live!

Get 1:1 Help Now