Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Need button on Access 2013 form to print report with current record

Posted on 2014-08-11
6
Medium Priority
?
11,503 Views
Last Modified: 2014-09-03
Hi, I am new to Access but have managed to create a simple single table database, form and report.  One of my issues is how do I make this desktop database user friendly for users?  No one knows how to use Access here so will they have to go into access development area like I do and enter data?  Or is there a way to have the form show up in a GUI data entry environment?  The problem I have relating directly to the title is how do I program/code a command button to run a report I have created and only print the current record on the screen?  The report is called JobTicket and the form is called Job# Form.  I am able to create a button and use the wizard to print the JobTicket report but it always prints ALL the records, not just the current one.  Thank you very much.  Please be specific if answering because I am brand new to this.  Thank you!
0
Comment
Question by:mjchevalier
6 Comments
 
LVL 19

Accepted Solution

by:
Eric Sherman earned 1000 total points
ID: 40254677
Yes you can ... Just base your report off of a query object.  In your table you should have a field that uniquely identifies the current record the pointer is on.  

Then use this code behind your button to print your report.

If the field is Text ...
DoCmd.OpenReport "YourReportName", acViewNormal, , "[YourFieldName] = '" & Me.FieldName & "'"

If the field is a number ...
DoCmd.OpenReport "YourReportName", acViewNormal, , "[YourFieldName] ="  & Me.FieldName


ET
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40254812
<No Points wanted>

You should also save the current record first (so if any edits were made the changes will be reflected in the report.

DoCmd.RunCommand accmdsaverecord
DoCmd.OpenReport...
...
0
 
LVL 19

Expert Comment

by:Eric Sherman
ID: 40254921
Or ...

Me.Dirty = False


ET
0
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!

 
LVL 40

Assisted Solution

by:PatHartman
PatHartman earned 1000 total points
ID: 40255720
To make the database open to a form, use the Access Options dialog.  You get to this dialog different ways depending on the version of Access you are using.
Access Options
0
 

Author Comment

by:mjchevalier
ID: 40259096
Thank you all.  etsherman, I already built a report that has everything formatted correctly, so I am not sure what to do when you say, "just base your report off of a query object."  I don't know where to put the code that you gave me behind the button.  Can you please explain in complete novice details?  Thank you so much!
0
 
LVL 19

Expert Comment

by:Eric Sherman
ID: 40259295
<<<<<Thank you all.  etsherman, I already built a report that has everything formatted correctly, so I am not sure what to do when you say, "just base your report off of a query object."  I don't know where to put the code that you gave me behind the button.  Can you please explain in complete novice details?  Thank you so much! >>>>>

Change the Record Source of your report from your Table Object to a Query Object.  A Query will give you more flexibility when creating reports and forms like creating additional calculated fields and adding WHERE Clauses, etc.  Create a Select query named qryYourReportName and select the fields from your table.  Save it and use that for the Record Source ... not the table.  The code goes behind the button you are using to run the report.   How are you running the report???

Can you load up a sample database???  That would make things easier to explain once you see it.

ET
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

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

When we develop an application in Ms Access 2016 we should also try to protect the queries, macros and table links. I know I may not have a permanent solution but for novice users, they will not manage to break your application. Below is the detail …
A Case Study of using the Windows API to provide RS232 communications capability in Access without the use of Active-X controls.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

579 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