Re: load a filtered form based on user login

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



najah via AccessMonster.com wrote:
On my switchboard there is a command button to enter time which
launches the Time*** form in add mode. The
recordsource for this form is a table entitled Time***.

Their is also a button on the switchboard that allows them to
view/edit their time*** in the event they come across an error once
they have printed their time***.

I created a query with the criteria for EmployeeID=CurrentUser() and
changed the recordsource to match the
query so when I click the command button on the switchborad to
edit/view time*** it opens based on the user. However when I
click the button to enter time the form doesn't load because by
changing the recordsource to match the query it affected Time*** in
add mode.

This makes no sense. You said the enter time*** was based on a table
called Time***. The view/edit time*** you said is based on a query.
Changing the query has no impact on the table, so should not affect your
enter time***. Please clarify.

Also, I need the supervisors to be able to view all the records not
just theirs and with employeeID=currentuser that limits their view
also.

You can set the recordsource at runtime. There is a function in the
security FAQ you can use to determine if the currentuser is a member of a
security group. Use that to determine if they are a supervisor. i.e.

If faq_IsUserInGroup("Supervisors",CurrentUser) then
Me.RecordSource = "SELECT * FROM Time***"
Else
Me.RecordSource = "SELECT * FROM Time*** WHERE [EmployeeID] = " &
chr(34) & CurrentUser() & chr(34)
End If

You could put that in the open event of the view/edit form.


--
Joan Wild
Microsoft Access MVP


.


Quantcast