PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

create report based on data from other form?

 
 
Seddon Acaster
Guest
Posts: n/a
 
      15th Apr 2010
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?
 
Reply With Quote
 
 
 
 
Stefan Hoffmann
Guest
Posts: n/a
 
      15th Apr 2010
hi,

On 15.04.2010 12:58, Seddon Acaster wrote:
> 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 <--
 
Reply With Quote
 
Seddon Acaster
Guest
Posts: n/a
 
      17th Apr 2010
Thx Stefan. I tried this and all it did was show all entries rather those
filered by project_id.

Seddon

"Stefan Hoffmann" wrote:

> hi,
>
> On 15.04.2010 12:58, Seddon Acaster wrote:
> > 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 <--
> .
>

 
Reply With Quote
 
Stefan Hoffmann
Guest
Posts: n/a
 
      19th Apr 2010
hi Seddon,

On 17.04.2010 16:23, Seddon Acaster wrote:
> Thx Stefan. I tried this and all it did was show all entries rather those
> filered by project_id.

Then check whether you have the data source of your report crafted
correctly and that you have specified the parameter for the OpenReport
in the right command order. It must be the fourth parameter:

http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx


mfG
--> stefan <--
 
Reply With Quote
 
Seddon Acaster
Guest
Posts: n/a
 
      19th Apr 2010
This may or may not be relevant but I am using MS Access 2007.

"Stefan Hoffmann" wrote:

> hi Seddon,
>
> On 17.04.2010 16:23, Seddon Acaster wrote:
> > Thx Stefan. I tried this and all it did was show all entries rather those
> > filered by project_id.

> Then check whether you have the data source of your report crafted
> correctly and that you have specified the parameter for the OpenReport
> in the right command order. It must be the fourth parameter:
>
> http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx
>
>
> mfG
> --> stefan <--
> .
>

 
Reply With Quote
 
Seddon Acaster
Guest
Posts: n/a
 
      19th Apr 2010
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?

"Seddon Acaster" wrote:

> This may or may not be relevant but I am using MS Access 2007.
>
> "Stefan Hoffmann" wrote:
>
> > hi Seddon,
> >
> > On 17.04.2010 16:23, Seddon Acaster wrote:
> > > Thx Stefan. I tried this and all it did was show all entries rather those
> > > filered by project_id.

> > Then check whether you have the data source of your report crafted
> > correctly and that you have specified the parameter for the OpenReport
> > in the right command order. It must be the fourth parameter:
> >
> > http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx
> >
> >
> > mfG
> > --> stefan <--
> > .
> >

 
Reply With Quote
 
Stefan Hoffmann
Guest
Posts: n/a
 
      19th Apr 2010
hi Seddon,

On 19.04.2010 12:15, Seddon Acaster wrote:
> 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 <--
 
Reply With Quote
 
John Spencer
Guest
Posts: n/a
 
      19th Apr 2010
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

Stefan Hoffmann wrote:
> hi Seddon,
>
> On 19.04.2010 12:15, Seddon Acaster wrote:
>> 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 <--

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I create a report based on a form Tom Microsoft Access Reports 2 31st Jan 2010 11:15 AM
use a form to create a report based on a query =?Utf-8?B?VG9t?= Microsoft Access Reports 2 1st Feb 2007 06:51 PM
Need to create a report based on an open form Rich Schoenfeld Microsoft Access 1 11th Feb 2005 07:34 PM
create report based on form.. =?Utf-8?B?QW5uYQ==?= Microsoft Access 6 1st Dec 2004 07:29 AM
create report based on form.. =?Utf-8?B?QW5uYQ==?= Microsoft Access Reports 6 30th Nov 2004 07:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:36 AM.