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,607 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 47

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

736 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