Print current record on form into report (1 Viewer)

coolrunner

New member
Local time
Today, 17:01
Joined
Feb 19, 2011
Messages
7
Goodday

Ive been reading other threads on this and am failing to work out what im doing wrong.

Im trying to only print the current record on a form into a report

table = tblStation
primary key = StationID (Number)

form name = frmStation
report name = rptStation

I have tried in a button

DoCmd.OpenReport "rptStation", acPreview, , "[StationID]= forms!frmStation![StationID]"

Any Ideas would be great

Cheers
 

John Big Booty

AWF VIP
Local time
Today, 17:01
Joined
Aug 29, 2005
Messages
8,263
Try;
Code:
DoCmd.OpenReport "rptStation", acPreview, , "[StationID]= " & forms!frmStation![StationID]
The following should also work;
Code:
DoCmd.OpenReport "rptStation", acPreview, , "[StationID]= " & Me.StationID
 

coolrunner

New member
Local time
Today, 17:01
Joined
Feb 19, 2011
Messages
7
Cheers for the fast reply

Unfortunately neither of those methods work ever, nothing happens at all once i click the button.
 

John Big Booty

AWF VIP
Local time
Today, 17:01
Joined
Aug 29, 2005
Messages
8,263
The way I would do this is to put the following criteria in the query that is populating your report;
Code:
forms!frmStation!StationID
 

John Big Booty

AWF VIP
Local time
Today, 17:01
Joined
Aug 29, 2005
Messages
8,263
If StationID is a text value rather than numeric you will need the following;
Code:
DoCmd.OpenReport "rptStation", acPreview, , "[StationID]= '" & Me.StationID & "'"
 

John Big Booty

AWF VIP
Local time
Today, 17:01
Joined
Aug 29, 2005
Messages
8,263
... also your form frmStation must be open for this method to work, but I'm assuming you already know that :eek:
 

coolrunner

New member
Local time
Today, 17:01
Joined
Feb 19, 2011
Messages
7
None of these methods seem to work, im sadly at a lose

Ive attached the database if your willing to take a look.
 

Attachments

  • EmployeeDatabase - Copy.zip
    216.5 KB · Views: 130

John Big Booty

AWF VIP
Local time
Today, 17:01
Joined
Aug 29, 2005
Messages
8,263
The problem lies with your report. What you need do is get rid of all the blank pages. Have a look at your DB again, run the report using;
Code:
DoCmd.OpenReport "rptStation", acPreview, , "[StationID]= " & Me.StationID
now scroll through the pages till you find the one that hold the filtered record.
 

MayaMana

Registered User.
Local time
Today, 03:01
Joined
May 29, 2012
Messages
60
Is this what you are trying to do?

I changed the report so that it only cycles through the current record, and then I added a where condition on the open report button. Where the query StationID = the form StationID.
 

Attachments

  • EmployeeDatabase - Copy.accdb
    800 KB · Views: 154

coolrunner

New member
Local time
Today, 17:01
Joined
Feb 19, 2011
Messages
7
Cheers both of you for your help, set me on the right path, having explain what i was doing wrong was of great help!
 

Users who are viewing this thread

Top Bottom