
Signature
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
I am not sure, but i think it is also db dependand.
I know with oracle db it breaks at 1000
Jan Willem
> SQL = "SELECT FROM tblX WHERE Z not in ('a11','b22','c33','d44')"
>
[quoted text clipped - 18 lines]
>
> or is there a better way?
Evertjan. wrote on 17 May 2008 22:17:22 GMT:
> SQL = "SELECT FROM tblX WHERE Z not in ('a11','b22','c33','d44')"
> Is there a maximum length of this litteral array
> ('a11','b22','c33','d44') ?
> Or of the SQL string as such?
> I would like to test 3000 plus records of 10 chars each for the few
> odd ones out in one go.
> I am using the Jet engine.
> =============
> btw, can I use a real vbs array this way?
> Do I do this?
> a = "('" & join(arr,"','") & "')"
> SQL = "SELECT FROM tblX WHERE Z not in " & a
> or is there a better way?
How about dumping the values into a table and using a join them find out if
they exist in tblX?

Signature
Dan
Evertjan. - 19 May 2008 10:47 GMT
Daniel Crichton wrote on 19 mei 2008 in
microsoft.public.inetserver.asp.db:
> Evertjan. wrote on 17 May 2008 22:17:22 GMT:
>
[quoted text clipped - 23 lines]
> How about dumping the values into a table and using a join them find
> out if they exist in tblX?
Nice, I will try this out.

Signature
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
> SQL = "SELECT FROM tblX WHERE Z not in ('a11','b22','c33','d44')"
>
[quoted text clipped - 7 lines]
>
> I am using the Jet engine.
Previous answers may have touched on what I'm about to post, which is my
canned answer on this topic. Maybe it contains something the other responses
did not cover:
There are two solutions for this problem listed in the following KB article
(Q210530 - ACC2000: How to Create a Parameter In() Statement), found by
searching for the keywords "parameter list query" (no quotes) at
http://support.microsoft.com.
http://support.microsoft.com/support/kb/articles/Q210/5/30.ASP
The first solution uses Instr() to test the field values against the list in
the parameter. The second involves dynamically creating a SQL statement in
code.
Thanks to Paul Overway, here is a third solution, using the Eval function:
WHERE (((Eval([Table]![Field] & " In(" & [Forms]![Formname]![textboxname] &
")"))=True))
or, using a prompted parameter:
WHERE (((Eval([Table]![Field] & " In(" & [Enter List] & ")"))=True))
Thanks to Jeffrey A. Williams, here's a 4th solution:
If you don't mind adding a table to your database, and you're comfortable
dealing with possible multi-user issues, this will perform better than
either of the solutions that involve running a function (Instr or Eval) on
every row of your table:
Create a new table with two fields:
tblCriteria:
Criteria text
Selected boolean (yes/no)
Populate the table with your values and select a couple of items. Now you
can use this table in your query as such:
Select * from table1
inner join tblcriteria
on table1.[your criteria field] = tblcriteria.criteria
where tblcriteria.selected = true
You can easily setup a form (or subform) that is bound to tblCriteria and
allow the users the
ability of selecting which values they want.
Thanks to Michael Walsh, here's yet another way:
SELECT Table3.ConName, Table3.State, Table3.Zip
FROM Table3
WHERE "," & [list] & "," LIKE "*," & [ConName] & ",*"
with [param] some string like: '1,4,5,7'
note that there is no space after the commas.
It works simply. If AccountID is 45, clearly ',1,4,5,7,' LIKE
'*,45,*' returns false.
If AccountID is 4, on the other hand, ',1,4,5,7,' LIKE '*,4,*'
returns true.
So, you have, in effect, an IN( ) where the list is a parameter.

Signature
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Evertjan. - 19 May 2008 20:15 GMT
Bob Barrows [MVP] wrote on 19 mei 2008 in
microsoft.public.inetserver.asp.db:
> So, you have, in effect, an IN( ) where the list is a parameter.
Thanks Bob, Daniel and Johnie,
You got me thinking.
I think I did not put my problem correct to you and to myself.
I have a database list M [my list] with records,
where one field M7 is an unique number.
There is a similar list H [her list]
on another domain not under my programming,
having the same unique number as a field H9 in those records,
the other fields not being the same in both lists.
At present I use a programme showing
the records of her list not in my list,
having with H7 = H9,
that is simple to do,
by testing each incoming record H9
on a corresponding record in my list M with M7.
The other way around, testing is a record on my list M has NO!!
corresponding record on the external list H,
was the chalenge.
I wanted to do in one SQL execution using "NOT IN".
I found that I should not have bothered with NOT IN,
but use NOT EXISTS,
because, [I think],
I want to find records not existing,
not fields.
After first storing the external numbers in the temporary table H,
my solution is [using the Jet engine]:
SQL = _
"SELECT M.M7 FROM M WHERE NOT EXISTS "_
"(SELECT H.H9 FROM H WHERE M.M7 = H.H9)"
The result gives the records on my list M
having no corresponding record on her list H.
Works fast and is simple, at least to me. ;-)
Found deep in:
http://msdn.microsoft.com/en-us/library/aa140015.aspx

Signature
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)