Passing parameter from a form to a view / report in ADP (2003)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello
I have a form consisting of a list box and a command button. On pressing the
button, I want a report to show a list of records (the Recordsource is a
view), but only those where the value of one particular field is that same as
the one selected in the list box in the form.

How do I pass the value of the list box to the report to filter the records?
Merely putting [FieldName] = [Forms]![Formname]![Listbox name] doesn't work.
I know the value is being passed to the report itself as I have a textbox
that confirms the value selected on the Report - I just can't get it to
filter.

All ideas gratefully received

Rgds

Simon
 
Hello again

I have found a way round this. If any one else has the same problem, reply
to this post and I'll post my solution.

Regards

Simon
 
[FieldName] = ListBoxName.ItemData(ListBoxName.ListIndex)

If no item is selected in the List box then ListBoxName.ListIndex will be -1
so you could check for this when the button is pressed to make sure an item
is selected
before the report is launched.
 
I am having a similar problem. I have a query that gets a parameter from the
user, which lists the results on the continuous form they used to run the
query.

I need to print a report based on that data. I could use the same query but
I dont want the user to get asked the for the same information they just put
in. I need to pass the parameter they entered into another query for the
report. Tried a million ways to do it, but I just cant seem to get it
working.
 
Hello EH

What I did was to write some code into the On Open event on the report:

Private Sub Report_Open(Cancel As Integer)
Me.Filter = "<field name> =" & [Forms]![<name of form>]![<name of control>]
Me.FilterOn = True

End Sub

So what this does is feed the parameter returned from the query (the value
of the control - list box, text box or whatever) into the report filter, and
it is evaluated every time the report is opened. This will only work while
the form is open, though.

Good luck

Simon

EH said:
I am having a similar problem. I have a query that gets a parameter from the
user, which lists the results on the continuous form they used to run the
query.

I need to print a report based on that data. I could use the same query but
I dont want the user to get asked the for the same information they just put
in. I need to pass the parameter they entered into another query for the
report. Tried a million ways to do it, but I just cant seem to get it
working.

Simon said:
Hello
I have a form consisting of a list box and a command button. On pressing the
button, I want a report to show a list of records (the Recordsource is a
view), but only those where the value of one particular field is that same as
the one selected in the list box in the form.

How do I pass the value of the list box to the report to filter the records?
Merely putting [FieldName] = [Forms]![Formname]![Listbox name] doesn't work.
I know the value is being passed to the report itself as I have a textbox
that confirms the value selected on the Report - I just can't get it to
filter.

All ideas gratefully received

Rgds

Simon
 
Back
Top