query criteria - global variable

  • Thread starter leahf via AccessMonster.com
  • Start date
L

leahf via AccessMonster.com

For a parameter for a report, I have a multiselect listbox to choose
districts.

Using a global variable, I form a string with all the codes of the districts
that were chosen. I have checked the string and the lists of district codes
are correct.

In the district code field of the query for the report, I put in the criteria
" In (getstrDistricts())".

When I choose one district it works. When I choose more than one district,
the report is blank.

What am I doing wrong?

Leah
 
G

Gary Walter

leahf said:
For a parameter for a report, I have a multiselect listbox to choose
districts.

Using a global variable, I form a string with all the codes of the
districts
that were chosen. I have checked the string and the lists of district
codes
are correct.

In the district code field of the query for the report, I put in the
criteria
" In (getstrDistricts())".

When I choose one district it works. When I choose more than one
district,
the report is blank.
Hi Leah,

In(...) just will not work that way...sorry.

Typically, you have a form with a list box,
you click on command button to open report,
and in code for that event you save "list" in a
variable (say "strList").

Then, just before you open report, you merge list
with IN

strWhere = "[somefield] IN (" & strList & ")"

and use strWhere in the report open command...

DoCmd.OpenReport stDocName, acPreview, , strWhere

Will that work for your situation?

good luck,

gary
 
L

leahf via AccessMonster.com

Worked like a charm.

Thank you very, very much.

Leah


Gary said:
For a parameter for a report, I have a multiselect listbox to choose
districts.
[quoted text clipped - 12 lines]
district,
the report is blank.

Hi Leah,

In(...) just will not work that way...sorry.

Typically, you have a form with a list box,
you click on command button to open report,
and in code for that event you save "list" in a
variable (say "strList").

Then, just before you open report, you merge list
with IN

strWhere = "[somefield] IN (" & strList & ")"

and use strWhere in the report open command...

DoCmd.OpenReport stDocName, acPreview, , strWhere

Will that work for your situation?

good luck,

gary
 

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