By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,256 Members | 1,700 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,256 IT Pros & Developers. It's quick & easy.

In-Operator and global variable

P: n/a
Jan
Hi,

I'm trying with a query. A criteria of the query is a global variable
represented as a function. The variable is the result of a multiselect
listbox.
The function looks like this:

Public Function GetString()
GetString = strCrit
End Function

The SQL statement looks like this:

SELECT tblDetails.Harbor, tblDetails.Charterer
FROM tblDetails
WHERE (((tblDetails.Harbor) In (GetString())) AND
((tblDetails.Charterer) Like 'Stora*'));

If I only have one value and would say tblDetails.Harbor = GetString()
it's all fine. But if I'm trying to use the In-Operator there will be
no results in this query.

Any idea? Thanks for reading.
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I don't think you can store a query like this.
But you can build it on the fly:

SQLStr="SELECT tblDetails.Harbor, tblDetails.Charterer
FROM tblDetails
WHERE (((tblDetails.Harbor) In (" & GetString() & ")) AND
((tblDetails.Charterer) Like 'Stora*'));"
(take care of word wrap yourself).

What you're going to do with the results of this query would determine what
you do with SQLStr.

HTH
- Turtle

"Jan" <ei****@bego.com> wrote in message
news:34**************************@posting.google.c om...
Hi,

I'm trying with a query. A criteria of the query is a global variable
represented as a function. The variable is the result of a multiselect
listbox.
The function looks like this:

Public Function GetString()
GetString = strCrit
End Function

The SQL statement looks like this:

SELECT tblDetails.Harbor, tblDetails.Charterer
FROM tblDetails
WHERE (((tblDetails.Harbor) In (GetString())) AND
((tblDetails.Charterer) Like 'Stora*'));

If I only have one value and would say tblDetails.Harbor = GetString()
it's all fine. But if I'm trying to use the In-Operator there will be
no results in this query.

Any idea? Thanks for reading.

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.