Solved

How to print only current record?

Posted on 1997-11-17
4
321 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
  • 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

770 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