Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing a report for only the current record 1

Status
Not open for further replies.

KerryL

Technical User
May 7, 2001
545
US
I'm writing a simple database for a Help Desk so they can track incoming trouble calls. When a new call is entered, I want the operator to be able to print the new record. However, I don't want to just print the form, so adding a "Print Record" command button didn't work.

I'd like to print the record using a report format that I've already set up. But when I add a command button to print that report, it prints all the records.

How can I print the report for just the record on the current form?

Form = frmEnterCall
Report = rptCaseReport

Thanks in advance,
KerryL

 
When entering the details into the form is there a unique identifier. If there is just build a query which filters to that record then base the query on it.

Something like

[Forms]![FrmEnterCall]![CallNo]

In the call No field (if you have one) criteria. The form can be left as it is and the button should only print out this record.

Hope this helps, let me know if it does.
Rob!
 
Hi

Look at the code in the onclick event of the button, generated by the wizard, set the varable stlinkcritiria to an exprseeion to idetify the current record eg something like

"PrimeKey = " & [Primekey]

using your own field names of course

if the field is a string rather than a number you will need

"PrimeKey = '" & [Primekey] & "'" Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
kenneth.reaySPAMNOT@talk21.com
remove SPAMNOT to use
 
KerryL,

One more thing. If the user will print the record from the screen they are entering it, you must make sure the record gets saved to the table first. The easiest way to do this is to use the Refresh method just before your OpenReport statement:
Code:
Forms!frmEnterCall.Refresh
 
Rob,
Yes, each case that is entered is assigned a case number. The object for it is txtCaseNo.

I assume then, that I must base the report on this query, correct?

Thanks, I'll give it a try.
 
Yes Build a query with all the field you need in the report. In the design view add the following to the txtCaseNo criteria

[Forms]![FrmEnterCall]![txtCaseNo]

Then just turn the control of your current report to this new query, and this should be OK.

Let me know if this helps
Rob!
 
I have a report based on the same table as a form. This coding, linked to a command button, works well for me ... (You can tell I don't like coping with too many quotations marks - and I always open a report in Preview - just in case ...)

Dim strID as String
Dim strWHERE As String
Dim strQuote As String

strQuote = chr$(34)
strID = [YourFormName].[RecordID]
strWHERE = "[YourTable].RecordID = " & strQuote & strID & strQuote

DoCmd.OpenReport [YourReportName], acViewPreview, , strWHERE
 
Thanks Rob, it's working just fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top