Solved

Print Report based on Current Record

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bind Combobox 4 29
count unique records in access report 2 23
Replace NULL Value in Crosstab query with previous day data 6 29
append to an ms access field 6 21
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…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
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…
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…

911 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

16 Experts available now in Live!

Get 1:1 Help Now