?
Solved

Print Report based on Current Record

Posted on 2011-03-08
3
Medium Priority
?
706 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:Bill Doherty
[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
3 Comments
 
LVL 8

Assisted Solution

by:Andrew_Webster
Andrew_Webster earned 400 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 600 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:Bill Doherty
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
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 …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Suggested Courses

800 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