Print current record on form into report

coolrunner

New member
Local time
Tomorrow, 07:34
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
 
Try;
Code:
DoCmd.OpenReport "rptStation", acPreview, , "[StationID]= " & forms!frmStation![StationID]
The following should also work;
Code:
DoCmd.OpenReport "rptStation", acPreview, , "[StationID]= " & Me.StationID
 
Cheers for the fast reply

Unfortunately neither of those methods work ever, nothing happens at all once i click the button.
 
The way I would do this is to put the following criteria in the query that is populating your report;
Code:
forms!frmStation!StationID
 
If StationID is a text value rather than numeric you will need the following;
Code:
DoCmd.OpenReport "rptStation", acPreview, , "[StationID]= '" & Me.StationID & "'"
 
... also your form frmStation must be open for this method to work, but I'm assuming you already know that :o
 
None of these methods seem to work, im sadly at a lose

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

Attachments

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.
 
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

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

Back
Top Bottom