Items Selected in a ListBox as the Parameters for a Query Field

G

Guest

Let me start by apologizing. I'm almost certain that this has been answered
somewhere here before but I have searched and searched to no avail. Some of
the posts get really close and then they seem inevitably to be resolved in
private emails between the poster and the respondent.

Anyhow, I have a report. Its On Open property is set to open a criteria
form. This form contains a ListBox control and two Command Buttons, one Ok
and one Cancel. aach associated with an OK or Cancel macro respectively -
that way when the user clicks either, the form closes. At any rate, what I
want to do is pass the item(s) selected in the ListBox to a query parameter
(instead of using a standard parameter query) so that when the report opens
it displays the items selected from the ListBox. If you tell me which
property to associate it with, I can dumb the VBA code in - I just need to
know what the code should be, where it goes, and what the query criteria
should read.

Thanks in advance.
 
G

Guest

Douglas,

This was one of the posts I saw but I'm not sure I understand it. Where does
this code go. DO I create a hidden control on the form with this code. If so,
do I then reference that hidden control in the query and where (which
property) does this code fall into in the hidden control?

Thanks and sorry to be so obtuse. It seems like it should be relativley
simple.
 
D

Douglas J. Steele

Unfortunately, it ISN'T relatively simple.

Assuming you're using a command button to launch your report, you could put
that code in the Click event of the button to generate a WHERE clause, and
pass it as part of the OpenReport method.
 
G

Guest

Very well. I understand this. The only thing I need to know now is how to
reference this code (and the ctl.ItemsSelected item) in the query. Beyond
that I need to make sure that the OnClick event also closes the form as I
currently have that Event assigned to a macro that does that. Thanks again.
 

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

Top