Solved

Print Report based on Current Record

Posted on 2011-03-08
3
640 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now