Solved

Print Report based on Current Record

Posted on 2011-03-08
3
692 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 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: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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
default value of combobox 25 68
Calculate Weeks in A "Fiscal Month" 8 61
Access Runtime Error '3070' 5 48
Export individual report to pdf 2 38
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
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…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

739 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