How do I print one record in a MS Access 2007 form?

In MS Access 2007, I have a table setup with all of my contacts. I then created a form where i can select in individual contact and see all of their information. I am wanting to somehow print the information for the contact i choose on my form. I tried adding a print button, but it prints every single record in my table. I want it to print ONLY the contact i have selected on the form. Does that make sense? So, if i have 100 contacts in my contact table. I go to my form and select a contact John Doe. The contact information for John Doe is now showing on my form. I would like to print only John Doe's information as i am seeing it on the form. How can i best accomplish this? Thanks!!!!!
tols12Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
it will be better to use a report to Print information.
use the currently displayed record id in the form to filter the report

0
Rey Obrero (Capricorn1)Commented:
see this link

How to Print a Single Record from a Form in a Report
http://support.microsoft.com/?kbid=209560
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jeffrey CoachmanMIS LiasonCommented:
I agree with capricon1 that you should use a report for printing.

However, you can print the current form record with code like this on the click event of a button on your form:

    DoCmd.PrintOut acSelection


JeffCoachman
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

tols12Author Commented:
Perfect! So i put the "DoCmd.PrintOut acSelection" in and it prints. Now i just need to format the form so it prints on one page. right now it prints 4 pages. About a 1/2 inch of my form is printing on another page. How do i adjust the page setup for printing?
0
Dale FyeCommented:
As mentioned above, don't reformat your form so that it prints the way you want to, convert it to a report.

Open the form in design view, Select SaveAs, give it a new name, and select Report as the way to save it in the dropdown.  Now you can make minor changes to the formatting to ensure your report will print on a single page (or maybe two), instead of 4.  
0
tols12Author Commented:
So i saved it as a report. Now how do i create the link between my form and the report? Which coding are you referring to?
0
Rey Obrero (Capricorn1)Commented:
tols12,

did you look at the link i posted above ?
0
Dale FyeCommented:
Assuming that you have a field (ID) on your form which uniquely identifies that record, and the associated textbox control (txt_ID), and that the same field/controls exists in the report (which it will if you just did a SaveAs report).  Then the code behind your Print button would look like:

Private Sub cmd_Print_Click

    Docmd.openreport "reportname", acViewPreview, , "ID = " & me.txt_ID

End Sub

This would open the report in preview mode.  If you want to simply print it, just delete the acViewPreview value or replace it with acViewNormal.
0
tols12Author Commented:
I did. This is what i pasted in the coding. The last line starting with "DoCmd" is highlighted in yellow. I get an error.

Private Sub cmdPrintRecord_Click()

   Dim strReportName As String
   Dim strCriteria As String
   
   strReportName = "Contact"
   strCriteria = "[ID]='" & Me![ID] & "'"
   DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
   
End Sub

I named the report "Contact".
0
Dale FyeCommented:
Chances are that your ID field is numeric, not a string, so replace:

strCriteria = "[ID]='" & Me![ID] & "'"

with

strCriteria = "[ID]=" & Me![ID]
0
tols12Author Commented:
fyed, that worked. Now i will just adjust the report to fit. Thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
0
Rey Obrero (Capricorn1)Commented:
is the name of the field for the record Identification  ID ?
is the field a Number or Text Data type ?
0
tols12Author Commented:
Thank you for helping and being patient with me! I appreciate all of your help!!!!!
0
Jeffrey CoachmanMIS LiasonCommented:
...see how much easier printing is when using reports...?

;-)
0
tols12Author Commented:
It is a ton easier. :) I have learned something today! Thanks again for all of your help!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.