How to return an array (VB) and use it in a querry?

joseph1234

New member
Local time
Today, 11:42
Joined
Jun 5, 2008
Messages
3
Hello everybody. It's my first post :)

I have a function which returns an array:

Dim myArray(5)
Public Function getMyArray()
getMyArray = myArray
End Function

And now I'd like to do some query..something like this

Select * From MyTable where MyTable.id IN (getMyArray());


When I use it with an other function which returns a single variable ( eg. getId()), it works fine. How to do the same with an array. :confused:

I'm begging you help.
 
Simple Software Solutions

What is contained in the array?
Are they delimited?
Are they strings, dates, numbers, etc?
Never used the In() functionality this way before, good idea but I don't know if the methodology will work.

Also your array is a single array (vertical), may work if you declare it as a multi directional (horizontal). Just a thought.

CodeMaster::cool:
 
Thanks for your quick reply.

This is one dimensin array of Integers.
Every time I add new element into my array I use:

ReDim Preserve ar(cnt)
ar(cnt) = newValue
cnt= cnt+ 1

I have no idea how to chagne it into horizontal version.

If this wouldn't work do you have an idea how to replace In() into some other function ? ..or rewrite the query and returning function that the final query result would be the same.
 
Why use an array? If you used a table to store your data you could use a simple inner join to select your data.
 
I use an array becasue the data stored in is temporary..anyway I resolved the problem :D :D

I just made my own In() function. Now in query I have
WHERE (((isIn([Tab].[field]))=1));
yeaa :>
 

Users who are viewing this thread

Back
Top Bottom