ComboBox Values Filter (1 Viewer)

waseem0888

Member
Local time
Today, 12:38
Joined
Jul 25, 2020
Messages
51
Hi All,

I have a login form with a username and password and then after that, there is one combo box to select the project which will give the user access to that project only and restrict the users not login to other projects and to all my forms project combo box is disabled I am using this technique to restrict users so they cannot select any other project value from the combo box and there is one specific user value name (HQ) when user login with that combo box is enabled and for to access all project list in combo box.
But now I have one more requirement There are some users who will need access to 2 or more specific projects so I want to enable combobox for them and I want to filter out the list of projects related to those users only. for other users who need access to one project from the combo box should show one value in the list and if the user is (HQ) then he should have a list of all projects in the combo box.

For Example:

I have combox box with values 416, 417, 418, 419,420

So user 1 will have to access 416 only in the list
User 2 will have access to, 416,418,419,
And the one more user with value (HQ) in the combo box will have all list of values in the list.

Please suggest how can i achieve this task to have multiple projects under one user.
or if there is any way the user log in without project selection and he will have access to a specific list of projects.

Thanks
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:38
Joined
Sep 21, 2011
Messages
14,305
Have a table that shows what projects they can have access to.
Look up the project and their userid with a DCount(). If result is zero, they do not have access.

Or use the table as the combo source, so you preent all the projects they are allowed, to the user.
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 04:38
Joined
Oct 29, 2018
Messages
21,473
If you're saying the project Combobox is on the login form; but you want the user to access more than one project, then that combobox probably doesn't belong in the login form. You may need a project menu form where they can select the project they want to work on from a list of projects they are allowed to access. You can limit the list in the combo by remembering the login information either by using a TempVar or just hiding the login form.
 
Last edited:

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 06:38
Joined
Feb 28, 2001
Messages
27,186
This is a case where you need to know the person before you know the possible projects. The simplest way to do this is to form what is called a Junction Table between User and Project. You make an entry in this junction table where you have a User ID and a Project ID as the only two fields in this table. Then you populate the project combo box based a filter such as "( UsrPrj.User = <some representation of current user ID> )"
 

waseem0888

Member
Local time
Today, 12:38
Joined
Jul 25, 2020
Messages
51
Please someone help me to create this functionality I am not familiar with access and don't understand how to do it. I have attached the sample. I need a user login without selecting the project on the login form. the project combo box will be on the form where the user will have a limit to the projects.
Thanks in advance.
 

Attachments

  • Sample.accdb
    504 KB · Views: 75

Gasman

Enthusiastic Amateur
Local time
Today, 12:38
Joined
Sep 21, 2011
Messages
14,305
Please someone help me to create this functionality I am not familiar with access and don't understand how to do it. I have attached the sample. I need a user login without selecting the project on the login form. the project combo box will be on the form where the user will have a limit to the projects.
Thanks in advance.
There is absolutely nothing there?
You have made no attempt yourself. :(

Where is the user password meant to come from?
At the very least you need to have a password somewhere to check against.
If password enetered is correct then open the Project form. I would store the userid as a Tempvar, so I could refer to it anywhere else from now on.
The source for the combo would be any project that the user can access. As you have projects and employees, I would expect a junction table that links both (unless a user only has one project?, and if that was the case, no need for the combo?)
So you need another table that links Projects and Employees, just the FKs unless different data is required.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 12:38
Joined
Feb 19, 2013
Messages
16,613
You need 3 tables as a minimum

a table for users - userpk, loginname, password
A table of projects- projectpk, projectname
And table to join them - joinpk, userfk, projectfk

process

user logs in with reference to user table
Once password verified, display list of projects by reference to the join table linked to the project table and filtered on userfk
 

waseem0888

Member
Local time
Today, 12:38
Joined
Jul 25, 2020
Messages
51
@Gasman
I am sorry about that Actually I have done it on my main app so I thought maybe it was not the proper way to do it so I deleted it to have professional help.

I have attached the file the way I do it. But not understanding how to do it exactly to allow users to specific users in the project combo box.

Earlier I was logging user with the project list combo box on the login form and then disabling the project combo box based on the user type and for user type (HQ) it was able to get all lists from combo box
 

Attachments

  • Sample.accdb
    704 KB · Views: 65

Gasman

Enthusiastic Amateur
Local time
Today, 12:38
Joined
Sep 21, 2011
Messages
14,305
Well if you expect the user to swap projects, another form to select may be the way to go?
Otherwise they could just log out and in for each project and keep it the way it is.?
Just enable and update the project combo when you know the user id?
 

waseem0888

Member
Local time
Today, 12:38
Joined
Jul 25, 2020
Messages
51
Earlier I had a project selection list on the login form and then i had a user type column in the login table When the user login it checks the user type if its S (Site user) then it will disable the combo box on all my forms to not select the project instead only default project will come to the user they choose while login and then there is type H (Head Quarter) staff to see all the project of list to monitor all site data. I have attached the file I used the technique.

But now the issue is some users working on more than one project so disabling the combo box technique is not useful here.

My requirement is to limit the project list in the combo box to the specific user I will have 3 types of users.

User 1 will have access to a single project (Site User)
User 2 will have multiple two or more projects (Site User)
User 3 will have all projects accessible (Head office user)

So if project selection can be done on the login form and then the user logs out and logs in to another project with the same user ID then also fine.
Or if it can be a direct login without project selection on the login form and the user gets the list of projects based on their type either single project or multiple if it is possible then it will be best. (Like we have Aconex(Oracle) when users log in they will have a list of projects assigned to them.)

My goal is to limit the values in the project combo box based on the user. If this can be done through checkboxes so to which project is checked to the user that project only should have it in the list. or this can be done any other way.
 

Attachments

  • Sample.accdb
    864 KB · Views: 72

Gasman

Enthusiastic Amateur
Local time
Today, 12:38
Joined
Sep 21, 2011
Messages
14,305
When you get the userID/name, do requery the combo source.
Then check it's listcount
If it comes back more than one, enable the combo..
If just one, then use that combo value as their project without enabling the combo, just as you would if it was enabled.
 

Users who are viewing this thread

Top Bottom