Solved

Filter Error?

Posted on 2003-11-12
11
235 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
Comment Utility
Tbl_System.DB_Recs is a recordset.

   - Marc
0
 
LVL 4

Expert Comment

by:TomLaw1999
Comment Utility
Needs to be something like this

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

Author Comment

by:MarcGraff
Comment Utility
No diffrence. :(

   - Marc
0
 
LVL 5

Expert Comment

by:rpai
Comment Utility
Try this: -
Tbl_System.DB_Recs.Filter = "SysID = 6"

Should work!

0
 
LVL 5

Expert Comment

by:rpai
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 1

Author Comment

by:MarcGraff
Comment Utility
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
Comment Utility
Please read this :- http://www.adopenstatic.com/faq/800a0cc1.asp
Might be of help.

0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
>>Tbl_System.DB_Recs is a recordset.

Is is a ADO recordset ?
0
 
LVL 39

Accepted Solution

by:
appari earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

763 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