Limit Query to Current User Name

M

Mark

I'm trying to build a query that will report production stats for system
users, but I'd like to limit the results to the current user. The username
is a field in the data, so I can query on it. But, is there a way to include
the current username is the query conditions without the user having to enter
it? I want for them to only see their own stats, not their team mates. I'm
sure it can be done; anybody know how?
Thanks in advance!
Mark
 
M

Mark

Yep, I'm querying from Access. I copied that code into a new module. I've
never created or used a module. How do I call it in my query?
 
D

Douglas J. Steele

Your query would be something like

SELECT Field1, Field2, Field3
FROM MyTable
WHERE UserID = fOSUserName()

Incidentally, if you're not used to code, make sure you didn't name the
module fOSUserName: modules cannot have the same name as functions or subs
contained within them.
 
M

Mark

Thank You!!! That worked. Thanks for clarifying about the module name. I
had indeed given it the same name as the function. Thanks for your help. I
appreciate it BIG Time.
 

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