create report based on data from other form?

  • Thread starter Thread starter Seddon Acaster
  • Start date Start date
S

Seddon Acaster

2x forms

one form contains addresses, each record shows a different address, each
record has a unique project_id

the other form contains invoices, each record shows a different invoice
number, date and project_id

i want a button on the address form that opens a report, the report only
shows those invoice records that have the same project_id as the record that
is currently viewed on the address form

how do i do this?
 
hi,

i want a button on the address form that opens a report, the report only
shows those invoice records that have the same project_id as the record that
is currently viewed on the address form

how do i do this?
Build your report. You must include the [project_id] field in its data
source.

When the report is done, place a button named btnReport on the form and
add a code event procedure:

Private Sub btnReport_Click()

DoCmd.OpenReport "ReportName", , , "[project_id] = " & Me![project_id]

End Sub


mfG
--> stefan <--
 
Thx Stefan. I tried this and all it did was show all entries rather those
filered by project_id.

Seddon

Stefan Hoffmann said:
hi,

i want a button on the address form that opens a report, the report only
shows those invoice records that have the same project_id as the record that
is currently viewed on the address form

how do i do this?
Build your report. You must include the [project_id] field in its data
source.

When the report is done, place a button named btnReport on the form and
add a code event procedure:

Private Sub btnReport_Click()

DoCmd.OpenReport "ReportName", , , "[project_id] = " & Me![project_id]

End Sub


mfG
--> stefan <--
.
 
My code is as follows:

DoCmd.OpenReport "test", acViewPreview, , "[project_id] = " & Me![project_id]

When button (with above code) is pressed I get following message box:

Enter Parameter Value

When I manually enter a value then the resulting report is displayed
correctly.

What am I doing wrong?
 
hi Seddon,

When button (with above code) is pressed I get following message box:

Enter Parameter Value
Ah, good.
When I manually enter a value then the resulting report is displayed
correctly.

What am I doing wrong?
This means that we have either a typo or reference error. For the typo
check the spelling of the parameter name as displayed in the input box
you're getting. For a reference error take a close look at your reports
data source: has the field a table name prefix in its design view?


mfG
--> stefan <--
 
Or it could be that Project_ID is not an number field. If that is the case
you need to change the call to

DoCmd.OpenReport "test", acViewPreview, ,
"[project_id]=""" & Me![project_id] & """"

Or alternative using ' instead of "
DoCmd.OpenReport "test",acViewPreview,,
"[project_id]='" & Me![project_id] & "'"

Watch out for the line wrap and that should all be on one line. The
newsreader will make that two lines.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
Back
Top