Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21284

Using 'IN' in a SQL Quiery

$
0
0
I have been asked to modify an old VB6 project. I am using a 'MDB' type database (Access etc;)

I have used the following SQL quiery in my code -

SQL = "SELECT Entries.[Win Position] as Win, Entries.[Class No], Entries.[Class Card No], Entrants.[Title], Entrants.[Name], Entrants.[Col3], Entrants.[Age] From Entries, Entrants Where Entries.[ID] = Entrants.[ID] AND Entries.[Win Position] <> '.' and Entries.[ID] = Entrants.[ID] AND Entries.[Win Position] <> '0' ORDER BY Entries.[Class No], Entries.[Win Position], Entrants.[Name];"

This works fine, but I need to narrow down the number of records selected. The 'Class Number' can contain up to 999 classes. I want to reduce the selection to a subset of this number.

I tried adding

AND Entries.[Class No] IN ValidClasses

where ValidClasses is a string which could be (50,51,52,53,) for example, or may contain a larger number of values. However, this creates a RunTime Error -2147217900 (80040e14)':

The Class Number is an Integer in the database, if this is relevant.

Any Suggestions please?

Nedwob

Viewing all articles
Browse latest Browse all 21284

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>