Restricting Certain Data when opening a form

gold007eye

Registered User.
Local time
Today, 17:57
Joined
May 11, 2005
Messages
260
What I have is a database that I am using for 3 different sites; NE, NCA, & SCA. What I want to do is have the form ONLY show information for the specific site that the Leader is a member of. I have a security table that contains the persons name, & site location. For example: John Smith works at the NE site; so when he goes to open a form to add/modify/delete members from his site I want him to only be able to see date for NE from the table. So in the listbox NCA & SCA would be filtered.

How can I go about doing this? The forms Record Source is set to the Security Table. Please help so I can do this without having to create a seperate form for each different location. :)
 
Assuming you have the users network name in the security table, you can use Environ("UserName") to pick it up from the network.

Use a query with the datatable and the security table as a recordsource for the form - using the Environ() as criteria and match the SiteID in the datatable to the SiteID of the secirity table.

Then you'll get only those records showing with that particular SiteID

Col
 
I have the users name and ID setup in the security table. I am not very good with the VBA coding.. how would I use the Environ() and also how can i have the recordsource look at a table and a query at the same time? THanks for your help.
 
Forget having the form look at a table, it does it via a query.

In the query grid you add the 2 tables and link them via a common field (SiteID?)

Then in the criteria part of the query grid under the UserName field put this

Code:
Environ("UserName")

Then all records for that users site will be found.

Col
 

Users who are viewing this thread

Back
Top Bottom