Using login ID to filter report records

J

Joanna

How can I capture the user's Access login info to filter the results of a
report? The report is a time sheet, and employees are only supposed to view
their own info on the report. I thought if they're all loggin on separately
anyway, there's got to be a way to pass that info on to the report. Please
use laymen's terms if possible. Thank you!!
 
D

Douglas J. Steele

Grab the code from http://www.mvps.org/access/api/api0008.htm at "The Access
Web". Copy everything in the shaded area (between Code Start and Code End)
and paste it into a brand new module (not a class module nor a module
associated with a form or report). Make sure you don't name the module
apiGetUserName or fOSUserName.

When you're opening the report, use

DoCmd.OpenReport "NameOfReport", , , "[UserName] = '" & fOSUserName & "'"

That assumes that you have a field named UserName in the recordsource of
your report. Exagerated for clarity, that last parameter is

"[UserName] = ' " & fOSUserName & " ' "
 

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