Solved

Filter Error?

Posted on 2003-11-12
11
241 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
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

Independent Software Vendors: 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!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…
Suggested Courses
Course of the Month9 days, 3 hours left to enroll

615 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