Open and Preview a Single Record in a Report

  • Follow


I have a report where I would like to open and print only the chosen record.  
How to I specify the record?

Thanks
0
Reply Utf 4/6/2010 1:59:02 PM

Brian T wrote:

>I have a report where I would like to open and print only the chosen record.  
>How to I specify the record?


If you have a form where users can navigate to the desired
record, then add a command button to open the report.  The
code behind the button would look something like:

Dim stWhere As String
stWhere = "[primary key field]=" & Me.[primary key field]
DoCmd.OpenReport "report name", acviewPreview, , stWhere

-- 
Marsh
MVP [MS Access]
0
Reply Marshall 4/6/2010 3:13:39 PM


Thanks,  but is there a way to write the same thing into an embedded macro?

"Marshall Barton" wrote:

> Brian T wrote:
> 
> >I have a report where I would like to open and print only the chosen record.  
> >How to I specify the record?
> 
> 
> If you have a form where users can navigate to the desired
> record, then add a command button to open the report.  The
> code behind the button would look something like:
> 
> Dim stWhere As String
> stWhere = "[primary key field]=" & Me.[primary key field]
> DoCmd.OpenReport "report name", acviewPreview, , stWhere
> 
> -- 
> Marsh
> MVP [MS Access]
> .
> 
0
Reply Utf 4/7/2010 2:09:01 PM

I don't use macros so all I can do is assume there is a way.
Probably using the OpenReport action with:
	"[primary key field]=" & Me.[primary key field]
in the WhereCondition argument.
-- 
Marsh
MVP [MS Access]


Brian T wrote:
>Thanks,  but is there a way to write the same thing into an embedded macro?
>
>"Marshall Barton" wrote:
>> Brian T wrote:
>> >I have a report where I would like to open and print only the chosen record.  
>> >How to I specify the record?
>> 
>> 
>> If you have a form where users can navigate to the desired
>> record, then add a command button to open the report.  The
>> code behind the button would look something like:
>> 
>> Dim stWhere As String
>> stWhere = "[primary key field]=" & Me.[primary key field]
>> DoCmd.OpenReport "report name", acviewPreview, , stWhere

0
Reply Marshall 4/7/2010 4:11:01 PM

3 Replies
725 Views

(page loaded in 0.162 seconds)


Reply: