use currentuser as criteria for a query

  • Thread starter Thread starter Rick
  • Start date Start date
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
 
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
 
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
 
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.
 
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
 
Back
Top