How to change report of source...or something like that

  • Thread starter Thread starter Darrell Childress
  • Start date Start date
D

Darrell Childress

This is something that I run into constantly and am wondering if there
is an easier way to accomplish. To view certain information about an
order, the user will click a button on a switchboard; they are then
prompted for the order number, and the report displays. It's a report
with a parameter query as its source.

However, I also have a form that displays certain order info and I want
to make that same report accessible. In this scenario, the user opens
the form, finds the order, then clicks on a button to run the report.

What I have done in the past is create an additional report based on the
original, and changed the record source to a different query. This 2nd
query is based on the original query, but has the parameter set as
Forms!Form.field to pull the Order Number from the form. It simply
eliminates the need for the user to have to enter the Order Number. End
result...I have 2 reports and 2 queries almost identical. Is there an
easier way to accomplish this?
Thanks,
Darrell
 
Darrell said:
This is something that I run into constantly and am wondering if there
is an easier way to accomplish. To view certain information about an
order, the user will click a button on a switchboard; they are then
prompted for the order number, and the report displays. It's a report
with a parameter query as its source.

However, I also have a form that displays certain order info and I want
to make that same report accessible. In this scenario, the user opens
the form, finds the order, then clicks on a button to run the report.

What I have done in the past is create an additional report based on the
original, and changed the record source to a different query. This 2nd
query is based on the original query, but has the parameter set as
Forms!Form.field to pull the Order Number from the form. It simply
eliminates the need for the user to have to enter the Order Number. End
result...I have 2 reports and 2 queries almost identical. Is there an
easier way to accomplish this?


The usual way to do this kind of thing is to use a query
without the parameter criteria (i.e. the report will print
all records when opened from the database window).

Then the code behind the form's button whould use the
OpenReport method's WhereCondition argument to filter the
report's data. The code would be something like:

Dim stDoc As String
Dim stWhere As String
stDoc = "report name"
stWhere = "keyfield = " & Me.keyfield
DoCmd.OpenReport stDoc, acViewPreview, , stWhere
 
Back
Top