Microsoft Office Forums


Reply
Thread Tools Display Modes

Print report of current record from form

 
 
Denis
Guest
Posts: n/a
 
      05-08-2004, 04:36 AM
How can I create a command button in a form to print a
report containing data only from the current record In
Access 2003? The pertinent macro attached to the Command
Button wizard prints reports for all the records. I would
like to restrict it to the current record only.

Thanks, Denis.
 
Reply With Quote
 
 
 
 
Steve Schapel
Guest
Posts: n/a
 
      05-08-2004, 10:21 AM
Denis,

In the Where Condition argument of the OpenReport macro action, put the
equivalent of...
[ID]=[Forms]![NameOfForm]![ID]
(where ID is the primary key or otherwise field which uniquely
identifies each record in your form and report).

Another approach is to use a query as the record source for the report,
and in the criteria of the ID (or equivalent) field in the query, refer
to the current record in the form, e.g.
[Forms]![NameOfForm]![ID]

--
Steve Schapel, Microsoft Access MVP


Denis wrote:
> How can I create a command button in a form to print a
> report containing data only from the current record In
> Access 2003? The pertinent macro attached to the Command
> Button wizard prints reports for all the records. I would
> like to restrict it to the current record only.
>
> Thanks, Denis.

 
Reply With Quote
 
 
 
 
Cheryl Fischer
Guest
Posts: n/a
 
      05-08-2004, 12:56 PM
Denis,

You will need to add a Where Condition to the OpenReport method so that the
report shows only the information for the record displayed on your form. For
example, if the current record on your form was for a particular customer,
you could use the CustID field to determine the where condition as follows:

Dim strCriteria As String

' This works when your matching field is text
strCriteria = "[CustID] = " & Chr(34) & Me!CustID & Chr(34)
DoCmd.OpenReport "MyReport", acViewNormal, , strCriteria

' This works when your matching field is a number
strCriteria = "[CustID] = " & Me!CustID
DoCmd.OpenReport "MyReport", acViewNormal, , strCriteria

hth,


--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


"Denis" <(E-Mail Removed)> wrote in message
news:a26201c434b6$0d405a70$(E-Mail Removed)...
> How can I create a command button in a form to print a
> report containing data only from the current record In
> Access 2003? The pertinent macro attached to the Command
> Button wizard prints reports for all the records. I would
> like to restrict it to the current record only.
>
> Thanks, Denis.



 
Reply With Quote
 
Denis
Guest
Posts: n/a
 
      05-08-2004, 10:00 PM
Thanks a lot. It worked!!!

Denis

>-----Original Message-----
>Denis,
>
>You will need to add a Where Condition to the OpenReport

method so that the
>report shows only the information for the record

displayed on your form. For
>example, if the current record on your form was for a

particular customer,
>you could use the CustID field to determine the where

condition as follows:
>
> Dim strCriteria As String
>
> ' This works when your matching field is text
> strCriteria = "[CustID] = " & Chr(34) & Me!CustID &

Chr(34)
> DoCmd.OpenReport "MyReport", acViewNormal, ,

strCriteria
>
> ' This works when your matching field is a number
> strCriteria = "[CustID] = " & Me!CustID
> DoCmd.OpenReport "MyReport", acViewNormal, ,

strCriteria
>
>hth,
>
>
>--
>
>Cheryl Fischer, MVP Microsoft Access
>Law/Sys Associates, Houston, TX
>
>
>"Denis" <(E-Mail Removed)> wrote in

message
>news:a26201c434b6$0d405a70$(E-Mail Removed)...
>> How can I create a command button in a form to print a
>> report containing data only from the current record In
>> Access 2003? The pertinent macro attached to the

Command
>> Button wizard prints reports for all the records. I

would
>> like to restrict it to the current record only.
>>
>> Thanks, Denis.

>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

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
Button on form to print report for current record Anita Access General 4 05-02-2010 09:55 PM
Linking a PDF file of the current record to the current record Angie Access External Data 0 02-03-2006 09:08 PM
Print Report Record Matching Current Form Beverly76 Access Forms 2 12-19-2005 06:19 PM
Print the current record shown on form using a report Ricoy-Chicago Access Forms 1 03-07-2005 04:31 PM
Print Report of Current Record Shown on Form Bob Loder Access Beginners 6 10-14-2003 11:55 PM


All times are GMT. The time now is 06:41 PM.
Microsoft Office Forums is not affiliated with Microsoft Corporation.


Welcome!
Welcome to the Microsoft Office Forums
 


Latest Threads
New user looking for shapes/templates
SargeUSMC (04-21-2014, 04:23 PM)

Mail Merging Content With High Quality
oleander (04-17-2014, 11:59 PM)

Aargh. What is this?
PeteJ (04-17-2014, 12:10 PM)

Word 2013 Insert Symbol (Not Responding)
tpthrshr (04-17-2014, 02:49 AM)

Can't save a large Word document
Josh (04-17-2014, 01:03 AM)