open a Report to a specific record

S

smason

Hello!

I have form which collects data against memebers of staff! what i would
like to do is open a report which shows only the memeber of staff which is
curently displayed!

so i have made the report there is the staffID on both the report and form
for the link i want to add a 'button' on the form which opens the report
showing only the current staff member data!

if this makes!
 
S

smason

here is the code i have writen
DoCmd.OpenReport ("report test"), acViewPreview, "Employee ID=" &
"me.Employee ID", , acWindowNormal
 
D

Douglas J. Steele

Just a few errors. The Filter needs to be the 4th parameter, not the 3rd. As
well, the reference to the EmployeeID on the form needs to be outside of the
quotes (otherwise it's going to be treated as a literal text string).
Finally, since you've got a space in Employee ID (not a great idea), you
need square brackets around the references to it:

DoCmd.OpenReport ("report test"), acViewPreview, , _
"[Employee ID]=" & Me.[Employee ID], , acWindowNormal

(I put the line continuation in there to avoid confusion)

That assumes that Employee ID is a numeric field. If it were text, you'd
need quotes around the value:

DoCmd.OpenReport ("report test"), acViewPreview, , _
"[Employee ID]=""" & Me.[Employee ID] & """", , acWindowNormal

(that's three double quotes in front, and four double quotes after).
 
S

smason

works a treat thanks

Douglas J. Steele said:
Just a few errors. The Filter needs to be the 4th parameter, not the 3rd. As
well, the reference to the EmployeeID on the form needs to be outside of the
quotes (otherwise it's going to be treated as a literal text string).
Finally, since you've got a space in Employee ID (not a great idea), you
need square brackets around the references to it:

DoCmd.OpenReport ("report test"), acViewPreview, , _
"[Employee ID]=" & Me.[Employee ID], , acWindowNormal

(I put the line continuation in there to avoid confusion)

That assumes that Employee ID is a numeric field. If it were text, you'd
need quotes around the value:

DoCmd.OpenReport ("report test"), acViewPreview, , _
"[Employee ID]=""" & Me.[Employee ID] & """", , acWindowNormal

(that's three double quotes in front, and four double quotes after).

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


smason said:
here is the code i have writen
DoCmd.OpenReport ("report test"), acViewPreview, "Employee ID=" &
"me.Employee ID", , acWindowNormal
 
N

Neil

I found this quite useful. however, can you help Mr. Steele? it is the same
like this.

In a form, I created a combo list box where i stored Employee No to choose
from. I also created a command button to open a form on the specific Employee
No, however, when i try opening the form, it always goes to the beginning
Employee No. and not the specific Employee.


Douglas J. Steele said:
Just a few errors. The Filter needs to be the 4th parameter, not the 3rd. As
well, the reference to the EmployeeID on the form needs to be outside of the
quotes (otherwise it's going to be treated as a literal text string).
Finally, since you've got a space in Employee ID (not a great idea), you
need square brackets around the references to it:

DoCmd.OpenReport ("report test"), acViewPreview, , _
"[Employee ID]=" & Me.[Employee ID], , acWindowNormal

(I put the line continuation in there to avoid confusion)

That assumes that Employee ID is a numeric field. If it were text, you'd
need quotes around the value:

DoCmd.OpenReport ("report test"), acViewPreview, , _
"[Employee ID]=""" & Me.[Employee ID] & """", , acWindowNormal

(that's three double quotes in front, and four double quotes after).

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


smason said:
here is the code i have writen
DoCmd.OpenReport ("report test"), acViewPreview, "Employee ID=" &
"me.Employee ID", , acWindowNormal
 

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