Solved

Print Report based on Current Record

Posted on 2011-03-08
3
663 Views
Last Modified: 2012-05-11
I have been trying to print a report based on a current record being displayed in a form.

the form Name is Input, the Report name is Reminder the uigue feild in the table is ID and on the form it is ResNum they are set to have the same value ( I populate ResNum with the value of ID)

For a couple of days I have tried every suggestion I could find in this forum but the results are not what I am looking for.  I either get the Input parameter box for ID or I get the report opening only tothe fiirst record or a blank record.

I am using a print button with event procdure as follows (the most recommended to use)

    Dim stDocName As String
    Dim stWhereCriteria As String
 
    stDocName = "Reminder"
    stWhereCriteria = "[tReservations].[ID]=" & Me.ResNum
    DoCmd.OpenReport stDocName, acPreview,,stWhereCriteria

What am I doing wrong? I even tried to use the embedded code that was result of butto wizard with where info but nne of it successful

thanks
0
Comment
Question by:mwpai
3 Comments
 
LVL 8

Assisted Solution

by:Andrew_Webster
Andrew_Webster earned 100 total points
ID: 35072705
Try changing Me.ResNum to Me.ID    

    Dim stDocName As String
    Dim stWhereCriteria As String
 
    stDocName = "Reminder"
    stWhereCriteria = "[tReservations].[ID]=" & Me.ID
    DoCmd.OpenReport stDocName, acPreview, , stWhereCriteria

See if that works.
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 150 total points
ID: 35072728
A different way of looking at this so that it may make more sense...

    Dim stDocName As String
    Dim stWhereCriteria As String
 
    stDocName = "Reminder"
    stWhereCriteria = "[TheReportFieldThatCorrespondsDirctlyToResNumOnTheForm]=" & Me.ResNum
    DoCmd.OpenReport stDocName, acPreview,,stWhereCriteria

Also note that the above is for Numeric vales, for text try something like this:
    Dim stDocName As String
    Dim stWhereCriteria As String
 
    stDocName = "Reminder"
    stWhereCriteria = "[TheReportFieldThatCorrespondsToResNumOnTheForm]=" & "'" & Me.ResNum & "'"
    DoCmd.OpenReport stDocName, acPreview,,stWhereCriteria

Post back with your results...

JeffCoachman
0
 

Author Closing Comment

by:mwpai
ID: 35073838
this is what made it alll clear:
TheReportFieldThatCorrespondsToResNumOnTheForm

I never placed the ResNum or ID field onto the report!

thanks for the help
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
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…
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

776 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