Print Current Record in Report View

  • Thread starter sharann via AccessMonster.com
  • Start date
S

sharann via AccessMonster.com

Hello,

I am using the following code below to print a report based on
the current record in the form. My problem is, I have a unique identifer
[Emp ID #] that can have multiple dates associated with it. If a user goes
into the form and wants to only print preview that current record on the form
the report does view it but also all the other dates associated with the
[Emp ID #].

How do I alter my code to show only that specific record on the screen minus
the other dates?

Private Sub Scott_report_Click()
On Error GoTo Err_Scott_report_Click

Dim stDocName As String

stDocName = "rpt_Scott"
DoCmd.OpenReport stDocName, acPreview, , "[Emp ID #] = Forms![Scott
Hallum]![Emp ID #]"

Exit_Scott_report_Click:
Exit Sub

Err_Scott_report_Click:
MsgBox Err.Description
Resume Exit_Scott_report_Click

End Sub

Any help is greatly appreciated...
Sharann
 
R

Rick B

I would think that you would just add a condition to the filter to include
the date...

DoCmd.OpenReport stDocName, acPreview, , "[Emp ID #] = Forms![Scott
Hallum]![Emp ID #] and [SomeDateField] =
Forms![ScottHallum]![SomeDateControl]"
 
G

Guest

Better yet, if the record has a primary key (which I would hope it does),
pass that in as the criteria instead of the Emp Id and Date.

Barry

Rick B said:
I would think that you would just add a condition to the filter to include
the date...

DoCmd.OpenReport stDocName, acPreview, , "[Emp ID #] = Forms![Scott
Hallum]![Emp ID #] and [SomeDateField] =
Forms![ScottHallum]![SomeDateControl]"

--
Rick B



sharann via AccessMonster.com said:
Hello,

I am using the following code below to print a report based on
the current record in the form. My problem is, I have a unique identifer
[Emp ID #] that can have multiple dates associated with it. If a user
goes
into the form and wants to only print preview that current record on the
form
the report does view it but also all the other dates associated with the
[Emp ID #].

How do I alter my code to show only that specific record on the screen
minus
the other dates?

Private Sub Scott_report_Click()
On Error GoTo Err_Scott_report_Click

Dim stDocName As String

stDocName = "rpt_Scott"
DoCmd.OpenReport stDocName, acPreview, , "[Emp ID #] = Forms![Scott
Hallum]![Emp ID #]"

Exit_Scott_report_Click:
Exit Sub

Err_Scott_report_Click:
MsgBox Err.Description
Resume Exit_Scott_report_Click

End Sub

Any help is greatly appreciated...
Sharann
 
S

sharann via AccessMonster.com

Very cool...it's working...thanks Rick!

Rick said:
I would think that you would just add a condition to the filter to include
the date...

DoCmd.OpenReport stDocName, acPreview, , "[Emp ID #] = Forms![Scott
Hallum]![Emp ID #] and [SomeDateField] =
Forms![ScottHallum]![SomeDateControl]"
[quoted text clipped - 31 lines]
Any help is greatly appreciated...
Sharann
 
S

sharann via AccessMonster.com

Thanks Barry...got it working.
Yep, there is a Pkey set for this...thanks again for the quick response!!!

Barry said:
Better yet, if the record has a primary key (which I would hope it does),
pass that in as the criteria instead of the Emp Id and Date.

Barry
I would think that you would just add a condition to the filter to include
the date...
[quoted text clipped - 38 lines]
 
R

Rick Brandt

Barry said:
Better yet, if the record has a primary key (which I would hope it
does), pass that in as the criteria instead of the Emp Id and Date.

Perhaps the combination of EmpId and the Date IS the primary key. Just because
many people *prefer* to use AutoNumbers as PKs does not mean that they are the
definition of a PK.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top