Solved

How to print only current record?

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access query with left expression 9 32
How can I create a table in a linked database, in VB? 7 17
Excess tables to Excel BackUp 3 29
Export Query data to excel file 14 39
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

864 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now