Query with Where in list doesn't work.

D

DocBrown

I hope someone can tell me what I'm missing here...

I have the following query:

SELECT ZipData.EventID, ZipData.ZipCode, ZipData.Count
FROM Events INNER JOIN ZipData ON Events.EventID=ZipData.EventID
WHERE ((Events.ProgramArea) In (Reports![Programs Activities
Cumulative]!ProgramArea_List)) And ((ZipData.EventID) In (2,4,7))
ORDER BY ZipData.ZipCode;

The ProgramArea field can have 5 different string values. The TextBox
ProgramArea_list is an unbound control that gets it's value from VBA code.
When the TextBox contains only one item in a list, the query works. When the
list contains more than one, it doesn't. No records are returned. When I put
in the literal strings it also works:

SELECT ZipData.EventID, ZipData.ZipCode, ZipData.Count
FROM Events INNER JOIN ZipData ON Events.EventID=ZipData.EventID
WHERE ((Events.ProgramArea) In ("Visual Arts","BioSite")) And
((ZipData.EventID) In (2,4,7))
ORDER BY ZipData.ZipCode;

I have tried building the list with Quote delimiters and without as follows:

Visual Arts <- works
BioSITE,Visual Arts <- Does not work
"BioSITE","Visual Arts" <- Does not work

Nothing I can figure out will make the first query work with more than one
item in the list. I am trying out the query in the SQL View of the query
builder.

Any ideas?

Thanks,
John
 
A

Allen Browne

So ProgramArea_List is a multi-select list box? If so, the query will not be
able to read it this way.

One way around the issue is to create a visual basic function that accepts 2
arguments - a value, and the list box - and returns True to the query if it
matches. The function would be declared like this:
Public Function IsInListBox(varValue As Variant, lst As Listbox) As
Boolean

The function loops through the ItemsSelected in the list box to see if the
value is found, returning True if it is, or False if it is not. In the WHERE
clause of the query, you call it like this:
WHERE (IsInListBox(Events.ProgramArea,
[Forms]![Form1]![ProgramArea_List]))

Note that this assumes the multi-select list box is on a *form*. You cannot
read it form a report like that.
 
D

DocBrown

ProgramArea_List is a ComboBox on a Report. When I assign the contents of the
combobox with one item, the query CAN read the contents and will display the
results. The problem is getting the query to work when there are more than
one items in the list. I'm trying to assign the contents of the box the list
values that the query will see as:

WHERE ((Events.ProgramArea) In ("Visual Arts","BioSITE"))

The query works if the contents of the combo box is:
Visual Arts

The Query doesn't work if the contents is anything else such as:
Visual Arts,BioSITE
"Visual Arts","BioSITE"
"Visual Arts"

I have not figured out how to make it work if that control is a text box or
List.. Is there another way to get the query to read a list at the time the
query is executed? Say from a variable in VBA, or other method? Again, it
does work with there is only one item in the list, but not when there are
more than one.

Thanks you very much for helping on this.
John

Allen Browne said:
So ProgramArea_List is a multi-select list box? If so, the query will not be
able to read it this way.

One way around the issue is to create a visual basic function that accepts 2
arguments - a value, and the list box - and returns True to the query if it
matches. The function would be declared like this:
Public Function IsInListBox(varValue As Variant, lst As Listbox) As
Boolean

The function loops through the ItemsSelected in the list box to see if the
value is found, returning True if it is, or False if it is not. In the WHERE
clause of the query, you call it like this:
WHERE (IsInListBox(Events.ProgramArea,
[Forms]![Form1]![ProgramArea_List]))

Note that this assumes the multi-select list box is on a *form*. You cannot
read it form a report like that.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

DocBrown said:
I hope someone can tell me what I'm missing here...

I have the following query:

SELECT ZipData.EventID, ZipData.ZipCode, ZipData.Count
FROM Events INNER JOIN ZipData ON Events.EventID=ZipData.EventID
WHERE ((Events.ProgramArea) In (Reports![Programs Activities
Cumulative]!ProgramArea_List)) And ((ZipData.EventID) In (2,4,7))
ORDER BY ZipData.ZipCode;

The ProgramArea field can have 5 different string values. The TextBox
ProgramArea_list is an unbound control that gets it's value from VBA code.
When the TextBox contains only one item in a list, the query works. When
the
list contains more than one, it doesn't. No records are returned. When I
put
in the literal strings it also works:

SELECT ZipData.EventID, ZipData.ZipCode, ZipData.Count
FROM Events INNER JOIN ZipData ON Events.EventID=ZipData.EventID
WHERE ((Events.ProgramArea) In ("Visual Arts","BioSite")) And
((ZipData.EventID) In (2,4,7))
ORDER BY ZipData.ZipCode;

I have tried building the list with Quote delimiters and without as
follows:

Visual Arts <- works
BioSITE,Visual Arts <- Does not work
"BioSITE","Visual Arts" <- Does not work

Nothing I can figure out will make the first query work with more than one
item in the list. I am trying out the query in the SQL View of the query
builder.

Any ideas?

Thanks,
John
 
D

DocBrown

Oh, I have also tried to read the list from a form, but it still doesn't
work. I will also try to use your concept of the query getting the results of
the function. That looks promising. I'll also work again with the form and
see if I missed something.

Thanks,
John

Allen Browne said:
So ProgramArea_List is a multi-select list box? If so, the query will not be
able to read it this way.

One way around the issue is to create a visual basic function that accepts 2
arguments - a value, and the list box - and returns True to the query if it
matches. The function would be declared like this:
Public Function IsInListBox(varValue As Variant, lst As Listbox) As
Boolean

The function loops through the ItemsSelected in the list box to see if the
value is found, returning True if it is, or False if it is not. In the WHERE
clause of the query, you call it like this:
WHERE (IsInListBox(Events.ProgramArea,
[Forms]![Form1]![ProgramArea_List]))

Note that this assumes the multi-select list box is on a *form*. You cannot
read it form a report like that.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

DocBrown said:
I hope someone can tell me what I'm missing here...

I have the following query:

SELECT ZipData.EventID, ZipData.ZipCode, ZipData.Count
FROM Events INNER JOIN ZipData ON Events.EventID=ZipData.EventID
WHERE ((Events.ProgramArea) In (Reports![Programs Activities
Cumulative]!ProgramArea_List)) And ((ZipData.EventID) In (2,4,7))
ORDER BY ZipData.ZipCode;

The ProgramArea field can have 5 different string values. The TextBox
ProgramArea_list is an unbound control that gets it's value from VBA code.
When the TextBox contains only one item in a list, the query works. When
the
list contains more than one, it doesn't. No records are returned. When I
put
in the literal strings it also works:

SELECT ZipData.EventID, ZipData.ZipCode, ZipData.Count
FROM Events INNER JOIN ZipData ON Events.EventID=ZipData.EventID
WHERE ((Events.ProgramArea) In ("Visual Arts","BioSite")) And
((ZipData.EventID) In (2,4,7))
ORDER BY ZipData.ZipCode;

I have tried building the list with Quote delimiters and without as
follows:

Visual Arts <- works
BioSITE,Visual Arts <- Does not work
"BioSITE","Visual Arts" <- Does not work

Nothing I can figure out will make the first query work with more than one
item in the list. I am trying out the query in the SQL View of the query
builder.

Any ideas?

Thanks,
John
 
D

DocBrown

I've just tried something even more basic. The results look the same, but I
don't know if the underlying reasons are the same.

I have the following query:

SELECT ZipData.EventID, ZipData.ZipCode, ZipData.Count
FROM Events INNER JOIN ZipData ON Events.EventID=ZipData.EventID
WHERE ((Events.ProgramArea) In (ProgramArea_list)) And ((ZipData.EventID) In
(2,4,7))
ORDER BY ZipData.ZipCode;

This generates a general Parameter query. Just as before, in the displayed
Dialog box, if I enter one item without quotes, the records are displayed.
When there are multiple items in a list no records are displayed.

John

Allen Browne said:
So ProgramArea_List is a multi-select list box? If so, the query will not be
able to read it this way.

One way around the issue is to create a visual basic function that accepts 2
arguments - a value, and the list box - and returns True to the query if it
matches. The function would be declared like this:
Public Function IsInListBox(varValue As Variant, lst As Listbox) As
Boolean

The function loops through the ItemsSelected in the list box to see if the
value is found, returning True if it is, or False if it is not. In the WHERE
clause of the query, you call it like this:
WHERE (IsInListBox(Events.ProgramArea,
[Forms]![Form1]![ProgramArea_List]))

Note that this assumes the multi-select list box is on a *form*. You cannot
read it form a report like that.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

DocBrown said:
I hope someone can tell me what I'm missing here...

I have the following query:

SELECT ZipData.EventID, ZipData.ZipCode, ZipData.Count
FROM Events INNER JOIN ZipData ON Events.EventID=ZipData.EventID
WHERE ((Events.ProgramArea) In (Reports![Programs Activities
Cumulative]!ProgramArea_List)) And ((ZipData.EventID) In (2,4,7))
ORDER BY ZipData.ZipCode;

The ProgramArea field can have 5 different string values. The TextBox
ProgramArea_list is an unbound control that gets it's value from VBA code.
When the TextBox contains only one item in a list, the query works. When
the
list contains more than one, it doesn't. No records are returned. When I
put
in the literal strings it also works:

SELECT ZipData.EventID, ZipData.ZipCode, ZipData.Count
FROM Events INNER JOIN ZipData ON Events.EventID=ZipData.EventID
WHERE ((Events.ProgramArea) In ("Visual Arts","BioSite")) And
((ZipData.EventID) In (2,4,7))
ORDER BY ZipData.ZipCode;

I have tried building the list with Quote delimiters and without as
follows:

Visual Arts <- works
BioSITE,Visual Arts <- Does not work
"BioSITE","Visual Arts" <- Does not work

Nothing I can figure out will make the first query work with more than one
item in the list. I am trying out the query in the SQL View of the query
builder.

Any ideas?

Thanks,
John
 
A

Allen Browne

DocBrown said:
ProgramArea_List is a ComboBox on a Report.

Unlike a list box, a combo can't be multi-select, so the suggested code is
not suitable.

Likewise, the combo can't be read from the report. Unlike a form, a report
doesn't have a current record.
 
D

DocBrown

I'm using the combo box as sort of a global location to store the text that
will be substituted into the Query string. I'm sure there are probably better
places to do that but it was the first one that occured to me.

Actually, I find that I can read from the combo box on the report. But I
can't read from a Text box or List box. I also can read from the Caption of a
Label.

I'm trying to create a parameter query that can accept a list of values so
that the WHERE part of query looks like:
WHERE ((Events.ProgramArea) IN ([ItemList]))
and behaves like:
WHERE ((Events.ProgramArea) IN ("Item 1","Item 2"))

Where the ItemList is obtained from a variable or some other location.

The real problem seems to be that I can't find a way to pass a list of
values into a query for the 'IN' construct.

No matter what I do to construct the ItemList and try to get the query to
read the list, I can't get the query to return any records if the list
contains more than one item.

So that it's clear why I don't just build the full query string, there's
more to my proposed query but this is the part that I can't get working. I
want the query to get different values depending on when it is invoked. I
plan to set the list, and then the query will be executed.
 
A

Allen Browne

Whether you can read a value from a report might depend on the version of
Access and the view you are using (such as the new Report view in A2007,
rather than Print Preview)

You cannot pass a list as a parameter to a query.

You can write a function that returns True for the cases where the value is
right, or False where it not.

I don't see how a combo (which is always single-value) relates to the IN
operator (which is useful for multiple values.)

I didn't follow the bit about not being able to write the SQL property of
the QueryDef.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

DocBrown said:
I'm using the combo box as sort of a global location to store the text
that
will be substituted into the Query string. I'm sure there are probably
better
places to do that but it was the first one that occured to me.

Actually, I find that I can read from the combo box on the report. But I
can't read from a Text box or List box. I also can read from the Caption
of a
Label.

I'm trying to create a parameter query that can accept a list of values so
that the WHERE part of query looks like:
WHERE ((Events.ProgramArea) IN ([ItemList]))
and behaves like:
WHERE ((Events.ProgramArea) IN ("Item 1","Item 2"))

Where the ItemList is obtained from a variable or some other location.

The real problem seems to be that I can't find a way to pass a list of
values into a query for the 'IN' construct.

No matter what I do to construct the ItemList and try to get the query to
read the list, I can't get the query to return any records if the list
contains more than one item.

So that it's clear why I don't just build the full query string, there's
more to my proposed query but this is the part that I can't get working. I
want the query to get different values depending on when it is invoked. I
plan to set the list, and then the query will be executed.

Allen Browne said:
Unlike a list box, a combo can't be multi-select, so the suggested code
is
not suitable.

Likewise, the combo can't be read from the report. Unlike a form, a
report
doesn't have a current record.
 
D

DocBrown

Ok, bottom line is can't pass a list as a parameter to a query.

Building on one of your earlier suggestions, I have a new tact.

Using this idea:
Public Function IsInListBox(varValue As Variant, lst As Listbox) As
Boolean [Snip]

WHERE (IsInListBox(Events.ProgramArea,
[Forms]![Form1]![ProgramArea_List]))

I have:

Public Function IsFooter() As Boolean

Public intFooter As Integer
If intFooter > 0 Then
IsFooter = True
Else
IsFooter = False
End If
End Function

AND

WHERE ( IsFooter() or ((Events.ProgramArea) In (Reports![Programs
Activities Cumulative]!ProgramArea_Box))) And ((ZipData.EventID) In (2,4,7))

The idea here is if the function returns true, then all records in the
EventID list are displayed. If false, then only the records that match the
ProgramArea_box and are in the EventID list will be printed. I have tried
this by forcing the true/false of the function and it displays the desired
records.

Is there a way for this function to return true when the subreport is
actually being formatted for the report footer and not the group section? Or
is there a property of the report or sections that I could check. I'm not
sure the global var is the best approach but it almost works.

Your ideas are giving me a lot of tools to look at. Thanks!!
John

Allen Browne said:
Whether you can read a value from a report might depend on the version of
Access and the view you are using (such as the new Report view in A2007,
rather than Print Preview)

You cannot pass a list as a parameter to a query.

You can write a function that returns True for the cases where the value is
right, or False where it not.

I don't see how a combo (which is always single-value) relates to the IN
operator (which is useful for multiple values.)

I didn't follow the bit about not being able to write the SQL property of
the QueryDef.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

DocBrown said:
I'm using the combo box as sort of a global location to store the text
that
will be substituted into the Query string. I'm sure there are probably
better
places to do that but it was the first one that occured to me.

Actually, I find that I can read from the combo box on the report. But I
can't read from a Text box or List box. I also can read from the Caption
of a
Label.

I'm trying to create a parameter query that can accept a list of values so
that the WHERE part of query looks like:
WHERE ((Events.ProgramArea) IN ([ItemList]))
and behaves like:
WHERE ((Events.ProgramArea) IN ("Item 1","Item 2"))

Where the ItemList is obtained from a variable or some other location.

The real problem seems to be that I can't find a way to pass a list of
values into a query for the 'IN' construct.

No matter what I do to construct the ItemList and try to get the query to
read the list, I can't get the query to return any records if the list
contains more than one item.

So that it's clear why I don't just build the full query string, there's
more to my proposed query but this is the part that I can't get working. I
want the query to get different values depending on when it is invoked. I
plan to set the list, and then the query will be executed.

Allen Browne said:
ProgramArea_List is a ComboBox on a Report.

Unlike a list box, a combo can't be multi-select, so the suggested code
is
not suitable.

Likewise, the combo can't be read from the report. Unlike a form, a
report
doesn't have a current record.
 
A

Allen Browne

If the function does not receive any parameter, the query optimiser calls it
only once. The query needs to pass in a field (even if the function doesn't
use it.)

In your case, you want to pass the function the value of the field to be
matched.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

DocBrown said:
Ok, bottom line is can't pass a list as a parameter to a query.

Building on one of your earlier suggestions, I have a new tact.

Using this idea:
Public Function IsInListBox(varValue As Variant, lst As Listbox) As
Boolean [Snip]

WHERE (IsInListBox(Events.ProgramArea,
[Forms]![Form1]![ProgramArea_List]))

I have:

Public Function IsFooter() As Boolean

Public intFooter As Integer
If intFooter > 0 Then
IsFooter = True
Else
IsFooter = False
End If
End Function

AND

WHERE ( IsFooter() or ((Events.ProgramArea) In (Reports![Programs
Activities Cumulative]!ProgramArea_Box))) And ((ZipData.EventID) In
(2,4,7))

The idea here is if the function returns true, then all records in the
EventID list are displayed. If false, then only the records that match the
ProgramArea_box and are in the EventID list will be printed. I have tried
this by forcing the true/false of the function and it displays the desired
records.

Is there a way for this function to return true when the subreport is
actually being formatted for the report footer and not the group section?
Or
is there a property of the report or sections that I could check. I'm not
sure the global var is the best approach but it almost works.

Your ideas are giving me a lot of tools to look at. Thanks!!
John

Allen Browne said:
Whether you can read a value from a report might depend on the version of
Access and the view you are using (such as the new Report view in A2007,
rather than Print Preview)

You cannot pass a list as a parameter to a query.

You can write a function that returns True for the cases where the value
is
right, or False where it not.

I don't see how a combo (which is always single-value) relates to the IN
operator (which is useful for multiple values.)

I didn't follow the bit about not being able to write the SQL property of
the QueryDef.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

DocBrown said:
I'm using the combo box as sort of a global location to store the text
that
will be substituted into the Query string. I'm sure there are probably
better
places to do that but it was the first one that occured to me.

Actually, I find that I can read from the combo box on the report. But
I
can't read from a Text box or List box. I also can read from the
Caption
of a
Label.

I'm trying to create a parameter query that can accept a list of values
so
that the WHERE part of query looks like:
WHERE ((Events.ProgramArea) IN ([ItemList]))
and behaves like:
WHERE ((Events.ProgramArea) IN ("Item 1","Item 2"))

Where the ItemList is obtained from a variable or some other location.

The real problem seems to be that I can't find a way to pass a list of
values into a query for the 'IN' construct.

No matter what I do to construct the ItemList and try to get the query
to
read the list, I can't get the query to return any records if the list
contains more than one item.

So that it's clear why I don't just build the full query string,
there's
more to my proposed query but this is the part that I can't get
working. I
want the query to get different values depending on when it is invoked.
I
plan to set the list, and then the query will be executed.

:

ProgramArea_List is a ComboBox on a Report.

Unlike a list box, a combo can't be multi-select, so the suggested
code
is
not suitable.

Likewise, the combo can't be read from the report. Unlike a form, a
report
doesn't have a current record.
 
D

DocBrown

The code is slightly different, the var is global:
Public intFooter As Integer
Public Function IsFooter() As Boolean

If intFooter > 0 Then
IsFooter = True
Else
IsFooter = False
End If
End Function

I was intending to set the intFooter to > 0 at the appropriate time. But if
there's a better way, I'm all ears (eyes).

DocBrown said:
Ok, bottom line is can't pass a list as a parameter to a query.

Building on one of your earlier suggestions, I have a new tact.

Using this idea:
Public Function IsInListBox(varValue As Variant, lst As Listbox) As
Boolean [Snip]

WHERE (IsInListBox(Events.ProgramArea,
[Forms]![Form1]![ProgramArea_List]))

I have:

Public Function IsFooter() As Boolean

Public intFooter As Integer
If intFooter > 0 Then
IsFooter = True
Else
IsFooter = False
End If
End Function

AND

WHERE ( IsFooter() or ((Events.ProgramArea) In (Reports![Programs
Activities Cumulative]!ProgramArea_Box))) And ((ZipData.EventID) In (2,4,7))

The idea here is if the function returns true, then all records in the
EventID list are displayed. If false, then only the records that match the
ProgramArea_box and are in the EventID list will be printed. I have tried
this by forcing the true/false of the function and it displays the desired
records.

Is there a way for this function to return true when the subreport is
actually being formatted for the report footer and not the group section? Or
is there a property of the report or sections that I could check. I'm not
sure the global var is the best approach but it almost works.

Your ideas are giving me a lot of tools to look at. Thanks!!
John

Allen Browne said:
Whether you can read a value from a report might depend on the version of
Access and the view you are using (such as the new Report view in A2007,
rather than Print Preview)

You cannot pass a list as a parameter to a query.

You can write a function that returns True for the cases where the value is
right, or False where it not.

I don't see how a combo (which is always single-value) relates to the IN
operator (which is useful for multiple values.)

I didn't follow the bit about not being able to write the SQL property of
the QueryDef.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

DocBrown said:
I'm using the combo box as sort of a global location to store the text
that
will be substituted into the Query string. I'm sure there are probably
better
places to do that but it was the first one that occured to me.

Actually, I find that I can read from the combo box on the report. But I
can't read from a Text box or List box. I also can read from the Caption
of a
Label.

I'm trying to create a parameter query that can accept a list of values so
that the WHERE part of query looks like:
WHERE ((Events.ProgramArea) IN ([ItemList]))
and behaves like:
WHERE ((Events.ProgramArea) IN ("Item 1","Item 2"))

Where the ItemList is obtained from a variable or some other location.

The real problem seems to be that I can't find a way to pass a list of
values into a query for the 'IN' construct.

No matter what I do to construct the ItemList and try to get the query to
read the list, I can't get the query to return any records if the list
contains more than one item.

So that it's clear why I don't just build the full query string, there's
more to my proposed query but this is the part that I can't get working. I
want the query to get different values depending on when it is invoked. I
plan to set the list, and then the query will be executed.

:

ProgramArea_List is a ComboBox on a Report.

Unlike a list box, a combo can't be multi-select, so the suggested code
is
not suitable.

Likewise, the combo can't be read from the report. Unlike a form, a
report
doesn't have a current record.
 
D

DocBrown

I ment to show that the intFooter is a global variable.

Public intFooter As Integer

Public Function IsFooter() As Boolean

If intFooter > 0 Then
IsFooter = True
Else
IsFooter = False
End If
End Function



DocBrown said:
Ok, bottom line is can't pass a list as a parameter to a query.

Building on one of your earlier suggestions, I have a new tact.

Using this idea:
Public Function IsInListBox(varValue As Variant, lst As Listbox) As
Boolean [Snip]

WHERE (IsInListBox(Events.ProgramArea,
[Forms]![Form1]![ProgramArea_List]))

I have:

Public Function IsFooter() As Boolean

Public intFooter As Integer
If intFooter > 0 Then
IsFooter = True
Else
IsFooter = False
End If
End Function

AND

WHERE ( IsFooter() or ((Events.ProgramArea) In (Reports![Programs
Activities Cumulative]!ProgramArea_Box))) And ((ZipData.EventID) In (2,4,7))

The idea here is if the function returns true, then all records in the
EventID list are displayed. If false, then only the records that match the
ProgramArea_box and are in the EventID list will be printed. I have tried
this by forcing the true/false of the function and it displays the desired
records.

Is there a way for this function to return true when the subreport is
actually being formatted for the report footer and not the group section? Or
is there a property of the report or sections that I could check. I'm not
sure the global var is the best approach but it almost works.

Your ideas are giving me a lot of tools to look at. Thanks!!
John

Allen Browne said:
Whether you can read a value from a report might depend on the version of
Access and the view you are using (such as the new Report view in A2007,
rather than Print Preview)

You cannot pass a list as a parameter to a query.

You can write a function that returns True for the cases where the value is
right, or False where it not.

I don't see how a combo (which is always single-value) relates to the IN
operator (which is useful for multiple values.)

I didn't follow the bit about not being able to write the SQL property of
the QueryDef.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

DocBrown said:
I'm using the combo box as sort of a global location to store the text
that
will be substituted into the Query string. I'm sure there are probably
better
places to do that but it was the first one that occured to me.

Actually, I find that I can read from the combo box on the report. But I
can't read from a Text box or List box. I also can read from the Caption
of a
Label.

I'm trying to create a parameter query that can accept a list of values so
that the WHERE part of query looks like:
WHERE ((Events.ProgramArea) IN ([ItemList]))
and behaves like:
WHERE ((Events.ProgramArea) IN ("Item 1","Item 2"))

Where the ItemList is obtained from a variable or some other location.

The real problem seems to be that I can't find a way to pass a list of
values into a query for the 'IN' construct.

No matter what I do to construct the ItemList and try to get the query to
read the list, I can't get the query to return any records if the list
contains more than one item.

So that it's clear why I don't just build the full query string, there's
more to my proposed query but this is the part that I can't get working. I
want the query to get different values depending on when it is invoked. I
plan to set the list, and then the query will be executed.

:

ProgramArea_List is a ComboBox on a Report.

Unlike a list box, a combo can't be multi-select, so the suggested code
is
not suitable.

Likewise, the combo can't be read from the report. Unlike a form, a
report
doesn't have a current record.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top