Solved

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

Posted on 2014-04-17
2
1,617 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 (Access MVP) earned 500 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
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…

688 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