Restricting Records to logged in users

leetx

New member
Local time
Today, 11:41
Joined
Mar 18, 2010
Messages
9
Hello - I am trying to build a database (Access 2010) for another department in my company to use. (It started simple, but as I'm sure you can appreciate has grown my more complicated.)

At any rate, I have a login form but I cannot figure out how to restrict the records on other forms to just those logged in. I have added various bits of code and tried to tweak it with no luck at all. (much of it has come from the sample databases on this and other forums). I'm learning VBA as I go - my guess is that I am just not tweaking the code enough...

The last bit of code I tried to use came from the same site that I used to build build the login form. However, it is not working to restrict the users.

Case 3: Restricting records on a form to ones assigned to the current user
In the On Open event of the form you place code like:
Me.Filter = “[UserID] = “ & Forms!frmLogin!cboUser
RunCommand acCmdApplyFilterSort​

I have tried replacing cboUser with User, which is the field on my login form. And then I changed UserID to NurseID - since that's the field on my timecard form. (I also changed the form name to match mine)

What I am trying to do is once a person logs into the database, their time card will open with a new record and their name already entered from the login form. I do not want them to be able to enter anything for anyone else. (The db will be split and I plan to add code to remove the ribbon, etc).

Secondly, when they click on the "Update Case Info" button, I need a similar thing to happen. The form should automatically recognize this is Nurse One, Nurse Two, etc and filter the subform with just the cases assigned to them.

I have attached a zipped test database. It's a duplicate of the "official" database with dummy information in it. The password for all users is 1234.

Please let me know if you need additional information. I appreciate any help or thoughts on what I am doing wrong.

Thank you!!
 

Attachments

Users who are viewing this thread

Back
Top Bottom