A report based on record shown

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hiya,

I have a small form with employee vacation days, and I want to have a small
report come up with the click of a button, but I only want it to report on
the person displayed in the form without prompting the user to enter a name.
Is there a way to tell the query/report/button to see the one user that's
being displayed and show only them instead of everyone in the database?

Thank you very much in advance!!
Stephanie
 
Hi Stephanie... i just learned this myself...
what you need to do is:
1. Create a query with your identifying variable (name or emp ID in your
case) and for criteria right click---'build' and select the same variable
from your form
2. Design the report
3. In the form create a command button that (under record operations)
previews a report, and select to preview the report you just created
4. Open the properties for the button and under the tab 'event' select '...'
next to 'on click' (this will open VBA), at the end of the line with 'DoCmd'
add a comma and the name of your query in step 1 so that it looks like this:
DoCmd.OpenReport stDocName, acPreview, "QueryName"
and that should do it!
 
Hiya,

I ended up with this line:
DoCmd.OpenReport "Rep-Dates", acViewPreview,
"[Name]=Forms!Form-EnterTime!Name"

Where Name is the field that I want within the form, Rep-Dates being the
report. Clicking my button still shows all employees in the database.

If it helps to know, I have two tables. One has name, shift, and a few
other pieces of info and the other has the days they take off for vacation.

Thank you for your help. :)
 
Hi Lynd,

I'm not sure exactly what happened, but when I click to go into my report,
it still shows all employees, instead of just the one selected. If you have
any more suggestions, or a what I might have done wrong, please let me know.
:) I replied to the other reply I got with some more info, maybe that'll
help.

Thank you!!
Stephanie
 
Add another comma

DoCmd.OpenReport "Rep-Dates", acViewPreview, ,"[Name]= '" &
Forms![Form-EnterTime]![Name] & "'"

--
Good Luck
BS"D


Luna Saisho said:
Hiya,

I ended up with this line:
DoCmd.OpenReport "Rep-Dates", acViewPreview,
"[Name]=Forms!Form-EnterTime!Name"

Where Name is the field that I want within the form, Rep-Dates being the
report. Clicking my button still shows all employees in the database.

If it helps to know, I have two tables. One has name, shift, and a few
other pieces of info and the other has the days they take off for vacation.

Thank you for your help. :)

Ofer Cohen said:
Check this link on "How To Print A Single Record from a Form into a Report"

http://www.databasedev.co.uk/print_form_record.html
 
Back
Top