?
Solved

MS Access 2010 - a button that will save a record and open a report for that record

Posted on 2014-04-17
2
Medium Priority
?
1,630 Views
Last Modified: 2014-05-08
Good afternoon - I'm creating an Access database to generate cab vouchers. A user presses a button, and is brought to a blank form. Information is then entered. At the bottom of the form, I need a button that saves the record, then opens a report - this report is the cab voucher. Every time I press the button, I get every cab voucher in the database - not the one that has just been entered.

How do I get the report to only generate the one record I just entered?
0
Comment
Question by:anglandp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40007344
you need to filter the report using the current record in the form.

something like this

docmd.openreport "reportName",,,"[CabID]=" & me.cabID

see this link  http://support.microsoft.com/kb/209560
0
 
LVL 48

Accepted Solution

by:
Dale Fye earned 2000 total points
ID: 40007345
You initially have to save the current record.

Then you have to pass a value to the OpenReport method that tells it to only generate the report for the selected record.  If your form is based on a table that has an autonumber (ID) field, you would normally do something like:

Private Sub cmd_Save_and_Print

     dim strCriteria as string

    me.dirty = True      'this saves the current record

    strCriteria = "[ID] = " & me.txt_ID

    docmd.OpenReport "rptName", acViewPreview, , strcriteria

End Sub
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

752 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