Open Report in Current Form Records only

gaccess

Registered User.
Local time
Tomorrow, 08:02
Joined
Apr 17, 2011
Messages
32
Hi I'm wanting to open a report to Print out just the information from the Current Record in Form View. I have a Command Button to a Macro
The action is Open Report the Report Name is Purchase Order the Where Condition is [Order Number]=[Forms]![Purchase Order]![Order Number]
Oh yes and Order Number is my ID for the corresponding Table and Form
Well the Report Opens with just the one record but only the labels show.
Ive been trawling forums for about four hours and have tried allsorts but this is the closest I have come to what I need (how sad is that:()
 
funny I've sent two replies but I don't know where they are
I put a link to the file on mediafire but they don't appear in this thread.
Anyway I've now attached the file
 

Attachments

I couldn't see a button or a report in your database so I've created both. The button only opens the report showing the current purchase order.

By the way, you should store the Supplier ID (ID) in the purchase order table, not the supplier name.

hth
Chris
 

Attachments

Create the form first with a name (REPORT NAME) and create a button in your form. Go to the button in design view, right click and click on Build. Type the following between the private sub and end sub:

DoCmd.OpenReport "REPORT NAME", acViewPreview, , "[PRIMARY KEY] = " & Me.PRIMARY_KEY
 
Hi guys
firstly sorry the attachment I made was an early version (must have been too late at night, hence no button or report) :o
I'm beginning to wonder if there is a problem with my install as having tried about 20 different solutions (all fairly similar) before I came onboard and now your reply version will not work. I have put your code into the current version (attached) and on clicking the button all I get is Error Message The expression On Click - produced the following error : Invalid Outside Procedure
the reason I really wonder about my install is because the code in "stopher" returned file is the same as "coynesj" "majority rules"

any clues

thanks for both replies
 

Attachments

You need to take a look at your code. At the moment it looks like this:

Code:
Option Compare Database

[COLOR="Red"]Y
End Sub[/COLOR]

Private Sub Preview_Button_Click()
DoCmd.OpenReport "Purchase Order", acViewPreview, , "[Order Number]=" & Me.Order_Number
End Sub

The bits that I've highlighted in red are causing your error. Remove them and the report will run.

Note that you have no Supplier record for Farmer so you will get a blank report for purchase order 100001. PO 10002 works fine though (apart from the message to decrease your report width).

hth
Chris
 
Hi
thanks for your help. I redid the code and fixed the report width, I'd like to say it worked but sadly on click it just stares back. Maybe I'll put it to one side and have a look another day :)
 
I'm not sure what you mean by "just stares back".

Did you see my second point. If you don't have a corresponding Supplier record then you will get a blank report (as was the case with 10001).

Chris
 
Sorry "stares back" is a technical term for "oh bugger" which is an Antipodean colloquialism for "its doing not what I wanted"
But wait there's more
I took it to work today and opened it on Access 2010 and hey it works so I did some work tidied it up and added a couple more reports and all is sweet.
So back home I open it with some trepidation (some faint glimmer of hope like expecting to win Lotto or something) and what do you know it all works.
Oh yes the supplier thing - will need to keep supplier table up to date -
Thanks again:)
 
You need to take a look at your code. At the moment it looks like this:

Code:
Option Compare Database
 
[COLOR=red]Y[/COLOR]
[COLOR=red]End Sub[/COLOR]
 
Private Sub Preview_Button_Click()
DoCmd.OpenReport "Purchase Order", acViewPreview, , "[Order Number]=" & Me.Order_Number
End Sub

The bits that I've highlighted in red are causing your error. Remove them and the report will run.

Note that you have no Supplier record for Farmer so you will get a blank report for purchase order 100001. PO 10002 works fine though (apart from the message to decrease your report width).

hth
Chris

How can this 'print' button be taken one step further and attach the report (current record of form) as a pdf grabing the email address off the form too??? I have little access experience and could give the name of the fields & form if that would help
 
I have a table called AllBuildingsTDoors and i've created a split screen form with half of the split form drawing data from that table in a Query named Query1. On a separate form named DoorTicketsF, I have another form that draws information from the split form query1 data. Then I have a Submit button and what I want to happen is have the current record I selected on the split form to show up on a new form called DoorTicketsF which it does and then when I hit submit on the DoorTicketsF form it would take only that record and open up a report called DoorR for only that record. I've tried these steps and linked up what the report is called "DoorR" and also put what my primary key is from the query which is now txtID

Option Compare Database

Private Sub Command35_Click()

DoCmd.OpenReport "DoorR", acViewPreview, , "[txtID] = " & Me.txtID

End Sub

This didn't work. I get a compile error, method or data member not found. Also, if there's a way to do this as a macro I'd appreciate it also. But help both ways would be great. Thanks. I've attached what the DoorTicketsF looks like.
 
Syntax:
DoCmd.OpenReport "REPORT NAME", acViewPreview, , "[PRIMARY KEY] = " & Me.PRIMARY_KEY


Uses:
DoCmd.OpenReport "Purchase Order", acViewPreview, , "[Order Number]=" & Me.Order_Number
 

Users who are viewing this thread

Back
Top Bottom