Solved

How to print only current record?

Posted on 1997-11-17
4
335 Views
Last Modified: 2008-03-04
Hi,
Using ACCESS 2.0 I made a samall application to print receipts for customers. I have a form to input data in a table "Transactions", a Query using that table, and a button [Report] on the form to print a receipt for the current displayed record (usually the record just entered and saved). The problem is that it prints all records instead of the current record only.
Please help.
Thanks
0
Comment
Question by:abdoudiaw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Expert Comment

by:Denver111497
ID: 1959882
What are you using to determine what the "currently displayed" record is?  This is obviously where the problem lies.
 Do you want to click on a [Report] button in your form, and print the receipt? Or do you want to go to the report manually, and print any report you choose?
The answer depends on what exactly you want to do.
0
 

Author Comment

by:abdoudiaw
ID: 1959883
I want to click on a [Report] button in my form, and print the receipt. Thank you for your help.
0
 

Author Comment

by:abdoudiaw
ID: 1959884
Edited text of question
0
 
LVL 1

Accepted Solution

by:
RHarwood earned 50 total points
ID: 1959885
Here is what you need to do:

1.  Create the button
2.  On the on click event add the following code (I am going to assume you have some Key field which I will call ReceiptNum.  You of course will have to put in your own field name.:

DoCmd DoMenuItem 0,0,4       (This saves the current record so if someone just made changes they will be committed to the database)

DoCmd OpenReport "ReceiptReport",,,"ReceiptNum = " & Me!ReceiptNum                (Note this example assumes that ReceiptNum is a number.  If your Key field is a text field then the code would be:

DoCmd OpenReport "ReceiptReport",,,"ReceiptNum = """ & Me!ReceiptNum & """"

For both of these examples the "ReceiptNum =" part is a where clause for the report.  You can put in many different things there such as if you wanted to print all the receipts for a particular customer you could use:

DoCmd OpenReport "ReceiptReport",,,"CustomerID = " & Me!CustomerID.

Hope this helps
DoCmd Oprn
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question