use currentuser as criteria for a query

R

Rick

I have a query that pulls up all assignments in our database. I want each
user to only see his/her assignments. I have tried entereing
=currentuser in the criteria for my UserID field, but it says it is
invalid. I have tried dbEngine(0).UserName but it is also invalid.
How do I set up a query to pull in only the current user's assignments?

Thanks!

Rick
 
G

Gerald Stanley

One way would be to create a Public Function whose result
is the value of CurrentUser. The public function could
then be referenced in the Query.

Hope This Helps
Gerald Stanley MCSD
 
R

Rick

Gerald:

Worked like a charm!! I already had a function to grab the network logon
which is even better in this case than grabbing the Access logon. Thanks!

Rick
 
D

Darrell Childress

How does one create a Public Function? I tried Help in Access and came
up with nothing. I would love to be able to use the same feature.
 
G

Gerald Stanley

Open a new module (not a class module), put in code
something like

Public Function CurrentUserName() As String
CurentUserName = CurrentUser
End Function

Save the module and the job's done.

Hope This Helps
Gerald Stanley MCSD
 

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