Previous Thread

8/18/2006 2:45:40 PM    Re: load a filtered form based on user login
If you are using the built-in security then set the record source of the 
 
Timesheet form to 
 
a query where the criteria under EmployeeID is =CurrentUser() 
 
-- 
 
Joan Wild 
 
Microsoft Access MVP 
 
najah via AccessMonster.com wrote:



8/18/2006 5:05:47 PM    load a filtered form based on user login
Hi all, 
 
My question is: 
 
I have a timesheet form that contains my depts employees timelog.  One of the 
 
fields is employeeID. 
 
I've created a switchboard where the employee clicks on a command button and 
 
it opens a form Timesheet which allows them to view/edit their time, However 
 
they have the capabilities to view all 9 employee's records. 
 
If possible, can someone help me with this task: 
 
I've created logins and passwords for each employee 
 
I need to create a code that does this: 
 
If the user login=john doe  then open a form so that it is filtered where the 
 
employeeID =John Doe. This way they can only view their info. 
 
I created an employee table/form that has [EmployeeID] and [EmployeeName] 
 
fields and when setting up the login I just assigned the user name to match 
 
the employeeID (consists of employees initials). 
 
-- 
 
Message posted via AccessMonster.com 
 
http://www.accessmonster.com/Uwe/Forums.aspx/access-tablesdbdesign/200608/1

8/18/2006 5:24:48 PM    Re: load a filtered form based on user login
Hey Najah, 
 
All you need to do is add criteria to the DoCmd.OpenForm line that opens your 
 
timelog form, that equals the EmployeeID. 
 
ie: 
 
Dim stCriteria As String 
 
stCriteria = "EmployeeID =" & Forms![NameOfLogInForm]![EmployeeID] 
 
'this is if EmployeeID is numeric 
 
use if text: 
 
stCriteria = "EmployeeID ='" & Forms![NameOfLogInForm]![EmployeeID] 
 
& "'" 
 
DoCmd.OpenForm "FormNameBeingOpened",,stCriteria 
 
HTH, 
 
Shane 
 
najah wrote: 
 
-- 
 
Message posted via http://www.accessmonster.com

8/18/2006 5:36:39 PM    Re: load a filtered form based on user login
Thanks Shane, 
 
I must let you know that I am fairly new to Access, so I am a little confused. 
 
I created logins via the security wizard. Am I supposed to create a login 
 
form and if so what fields do I include 
 
shanesullaway wrote: 
 
-- 
 
Message posted via AccessMonster.com 
 
http://www.accessmonster.com/Uwe/Forums.aspx/access-tablesdbdesign/200608/1

8/18/2006 10:04:13 PM    Re: load a filtered form based on user login
Joan, 
 
Thanks for your reply. I am glad to hear from you for I am new to access as 
 
well as access monster and as I read through the various forums I find you 
 
very knowledgeable. 
 
Let me explain in detail what goes on with this db. 
 
On my switchboard there is a command button to enter time which launches the 
 
Timesheet form in add mode. The employee selects his name from a drop down 
 
and enters a start and end date to reflect their biweekly time. They then 
 
enter their details of a workday in a subform entitled Timesheet Hours. After 
 
order entry their is a button on the form that opens a report which allows 
 
for printing. The recordsource for this form is a table entitled Timesheet. 
 
Their is also a button on the switchboard that allows them to view/edit their 
 
timesheet in the event they come across an error once they have printed their 
 
timesheet. 
 
of course, it is when they view/edit their timesheet is when i need the form 
 
to open for them to view just their time log. 
 
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 
 
timesheet 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 Timesheet in add mode. 
 
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. 
 
I hope I clarified this, please help me it is driving me crazy 
 
Najah 
 
Joan Wild wrote: 
 
-- 
 
Message posted via http://www.accessmonster.com