|
security
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
restrict combo box selection depending on userHi,
Any ideas how I can restrict the possible selections of a combo box depending on who is signed into the database? For example, in a client database, I have a form to select from a list of clients that the user can amend the details of, I would like to restrict that list to just show the clients under the control of the user signed in. I have another field in my table showing each client by controller. Thanks Ian. You'll need to include the Access username in your table of clients - i.e.
what clients the user is 'attached' to. Perhaps your controller field does this, or could do this. The you change the rowsource of your combo box to SELECT [Client] FROM MyTable WHERE [controller] = CurrentUser() CurrentUser returns the Access logon name. -- Show quoteHide quoteJoan Wild Microsoft Access MVP Ian Lloyd wrote: > Hi, > > Any ideas how I can restrict the possible selections of a combo box > depending on who is signed into the database? For example, in a client > database, I have a form to select from a list of clients that the > user can amend the details of, I would like to restrict that list to > just show the clients under the control of the user signed in. I have > another field in my table showing each client by controller. > > Thanks > > Ian. Thanks Joan, your solution works when a controller is logged into my system,
but if I log in as admin I can't see any of the clients to select from, do you know how I can work around this? Ian. Show quoteHide quote "Joan Wild" wrote: > You'll need to include the Access username in your table of clients - i.e. > what clients the user is 'attached' to. Perhaps your controller field does > this, or could do this. > > The you change the rowsource of your combo box to > SELECT [Client] FROM MyTable WHERE [controller] = CurrentUser() > > CurrentUser returns the Access logon name. > > > -- > Joan Wild > Microsoft Access MVP > > Ian Lloyd wrote: > > Hi, > > > > Any ideas how I can restrict the possible selections of a combo box > > depending on who is signed into the database? For example, in a client > > database, I have a form to select from a list of clients that the > > user can amend the details of, I would like to restrict that list to > > just show the clients under the control of the user signed in. I have > > another field in my table showing each client by controller. > > > > Thanks > > > > Ian. > > > You'll need to use code to set the rowsource of the combobox in this case.
In the Form's open event If CurrentUser() = 'Ian' then Me.cboWhatever.RowSource = "SELECT * FROM MyTable" Else Me.cboWhatever.RowSource = "SELECT * FROM MyTable WHERE [controller] = " & chr(34) & CurrentUser() & chr(34) End If A better solution would be to use the function in the security FAQ that determines if a user is a member of a group http://support.microsoft.com/?id=207793 Then you can use If faq_IsUserInGroup("Admins",CurrentUser) then Me.cboWhatever...etc. -- Show quoteHide quoteJoan Wild Microsoft Access MVP Ian Lloyd wrote: > Thanks Joan, your solution works when a controller is logged into my > system, but if I log in as admin I can't see any of the clients to > select from, do you know how I can work around this? > > Ian. > > "Joan Wild" wrote: > >> You'll need to include the Access username in your table of clients >> - i.e. what clients the user is 'attached' to. Perhaps your >> controller field does this, or could do this. >> >> The you change the rowsource of your combo box to >> SELECT [Client] FROM MyTable WHERE [controller] = CurrentUser() >> >> CurrentUser returns the Access logon name. >> >> >> -- >> Joan Wild >> Microsoft Access MVP >> >> Ian Lloyd wrote: >>> Hi, >>> >>> Any ideas how I can restrict the possible selections of a combo box >>> depending on who is signed into the database? For example, in a >>> client database, I have a form to select from a list of clients >>> that the user can amend the details of, I would like to restrict >>> that list to just show the clients under the control of the user >>> signed in. I have another field in my table showing each client by >>> controller. >>> >>> Thanks >>> >>> Ian. Hi Joan,
Thanks for your help, I've tried copying in your code into the open event of my form, and I believe it is partially working. Here is the code that I have copied in: If CurrentUser() = "iLloyd" Then Me.Combo10.RowSource = "SELECT TblClientMaster.Code, TblClientMaster.Name FROM TblClientMaster ORDER BY TblClientMaster.Name" Else Me.Combo10.RowSource = "SELECT TblClientMaster.Code, TblClientMaster.Name, TblEmployeeMaster.[user ID] FROM TblClientMaster INNER JOIN TblEmployeeMaster ON TblClientMaster.[Team Leader] = TblEmployeeMaster.[Employee Code] WHERE (TblEmployeeMaster.[user ID])=CurrentUser() ORDER BY TblClientMaster.Name" End If When I log in as someone other than myself the combo box is working perfectly, offering only the clients relating to the logged in Team Leader (Controller), however, when I log in as myself (iLloyd), the combo box is not offering any clients to choose from, although when I look at the query behind the row source it looks fine and the dataset it produces is the list of all clients as expected, for some reason they do not appear within the combo box in form view. I don't suppose you know what I'm doing wrong do you? Thanks again for all your help Ian. Show quoteHide quote "Joan Wild" wrote: > You'll need to use code to set the rowsource of the combobox in this case. > > In the Form's open event > If CurrentUser() = 'Ian' then > Me.cboWhatever.RowSource = "SELECT * FROM MyTable" > Else > Me.cboWhatever.RowSource = "SELECT * FROM MyTable WHERE [controller] = " & > chr(34) & CurrentUser() & chr(34) > End If > > A better solution would be to use the function in the security FAQ that > determines if a user is a member of a group > http://support.microsoft.com/?id=207793 > > Then you can use > > If faq_IsUserInGroup("Admins",CurrentUser) then > Me.cboWhatever...etc. > > > -- > Joan Wild > Microsoft Access MVP > > Ian Lloyd wrote: > > Thanks Joan, your solution works when a controller is logged into my > > system, but if I log in as admin I can't see any of the clients to > > select from, do you know how I can work around this? > > > > Ian. > > > > "Joan Wild" wrote: > > > >> You'll need to include the Access username in your table of clients > >> - i.e. what clients the user is 'attached' to. Perhaps your > >> controller field does this, or could do this. > >> > >> The you change the rowsource of your combo box to > >> SELECT [Client] FROM MyTable WHERE [controller] = CurrentUser() > >> > >> CurrentUser returns the Access logon name. > >> > >> > >> -- > >> Joan Wild > >> Microsoft Access MVP > >> > >> Ian Lloyd wrote: > >>> Hi, > >>> > >>> Any ideas how I can restrict the possible selections of a combo box > >>> depending on who is signed into the database? For example, in a > >>> client database, I have a form to select from a list of clients > >>> that the user can amend the details of, I would like to restrict > >>> that list to just show the clients under the control of the user > >>> signed in. I have another field in my table showing each client by > >>> controller. > >>> > >>> Thanks > >>> > >>> Ian. > > > Hello,
Well it seems that the username is case sensitive and it all works perfectly now I've specified my user id correctly, so please ignore my previous question. One more quick question though, I would like the first part of the IF statement to depend on the username being either myself or 2 other people, I've tried using the line : If CurrentUser() = "iLloyd" or "mClaridge" or "dPickering" Then but Access can't execute this code. Could you tell me what I should be using please. Thanks Ian. Show quoteHide quote "Ian Lloyd" wrote: > Hi Joan, > > Thanks for your help, I've tried copying in your code into the open event of > my form, and I believe it is partially working. > > Here is the code that I have copied in: > > If CurrentUser() = "iLloyd" Then > Me.Combo10.RowSource = "SELECT TblClientMaster.Code, TblClientMaster.Name > FROM TblClientMaster ORDER BY TblClientMaster.Name" > Else > Me.Combo10.RowSource = "SELECT TblClientMaster.Code, TblClientMaster.Name, > TblEmployeeMaster.[user ID] FROM TblClientMaster INNER JOIN TblEmployeeMaster > ON TblClientMaster.[Team Leader] = TblEmployeeMaster.[Employee Code] WHERE > (TblEmployeeMaster.[user ID])=CurrentUser() ORDER BY TblClientMaster.Name" > End If > > When I log in as someone other than myself the combo box is working > perfectly, offering only the clients relating to the logged in Team Leader > (Controller), however, when I log in as myself (iLloyd), the combo box is not > offering any clients to choose from, although when I look at the query behind > the row source it looks fine and the dataset it produces is the list of all > clients as expected, for some reason they do not appear within the combo box > in form view. > > I don't suppose you know what I'm doing wrong do you? > > Thanks again for all your help > > Ian. > > > "Joan Wild" wrote: > > > You'll need to use code to set the rowsource of the combobox in this case. > > > > In the Form's open event > > If CurrentUser() = 'Ian' then > > Me.cboWhatever.RowSource = "SELECT * FROM MyTable" > > Else > > Me.cboWhatever.RowSource = "SELECT * FROM MyTable WHERE [controller] = " & > > chr(34) & CurrentUser() & chr(34) > > End If > > > > A better solution would be to use the function in the security FAQ that > > determines if a user is a member of a group > > http://support.microsoft.com/?id=207793 > > > > Then you can use > > > > If faq_IsUserInGroup("Admins",CurrentUser) then > > Me.cboWhatever...etc. > > > > > > -- > > Joan Wild > > Microsoft Access MVP > > > > Ian Lloyd wrote: > > > Thanks Joan, your solution works when a controller is logged into my > > > system, but if I log in as admin I can't see any of the clients to > > > select from, do you know how I can work around this? > > > > > > Ian. > > > > > > "Joan Wild" wrote: > > > > > >> You'll need to include the Access username in your table of clients > > >> - i.e. what clients the user is 'attached' to. Perhaps your > > >> controller field does this, or could do this. > > >> > > >> The you change the rowsource of your combo box to > > >> SELECT [Client] FROM MyTable WHERE [controller] = CurrentUser() > > >> > > >> CurrentUser returns the Access logon name. > > >> > > >> > > >> -- > > >> Joan Wild > > >> Microsoft Access MVP > > >> > > >> Ian Lloyd wrote: > > >>> Hi, > > >>> > > >>> Any ideas how I can restrict the possible selections of a combo box > > >>> depending on who is signed into the database? For example, in a > > >>> client database, I have a form to select from a list of clients > > >>> that the user can amend the details of, I would like to restrict > > >>> that list to just show the clients under the control of the user > > >>> signed in. I have another field in my table showing each client by > > >>> controller. > > >>> > > >>> Thanks > > >>> > > >>> Ian. > > > > > > If CurrentUser() = "iLloyd" OR CurrentUser() = "mClaridge" OR...etc
If these three users are members of a group (that no one else is a member of), you'd be better off to use the IsUserInGroup function I pointed to you earlier. It's more maintainable if you add users or drop others. -- Show quoteHide quoteJoan Wild Microsoft Access MVP Ian Lloyd wrote: > Hello, > > Well it seems that the username is case sensitive and it all works > perfectly now I've specified my user id correctly, so please ignore > my previous question. > > One more quick question though, I would like the first part of the IF > statement to depend on the username being either myself or 2 other > people, I've tried using the line : > > If CurrentUser() = "iLloyd" or "mClaridge" or "dPickering" Then > > but Access can't execute this code. > Could you tell me what I should be using please. > > Thanks > > Ian. > > "Ian Lloyd" wrote: > >> Hi Joan, >> >> Thanks for your help, I've tried copying in your code into the open >> event of my form, and I believe it is partially working. >> >> Here is the code that I have copied in: >> >> If CurrentUser() = "iLloyd" Then >> Me.Combo10.RowSource = "SELECT TblClientMaster.Code, >> TblClientMaster.Name FROM TblClientMaster ORDER BY >> TblClientMaster.Name" >> Else >> Me.Combo10.RowSource = "SELECT TblClientMaster.Code, >> TblClientMaster.Name, TblEmployeeMaster.[user ID] FROM >> TblClientMaster INNER JOIN TblEmployeeMaster ON >> TblClientMaster.[Team Leader] = TblEmployeeMaster.[Employee Code] >> WHERE (TblEmployeeMaster.[user ID])=CurrentUser() ORDER BY >> TblClientMaster.Name" End If >> >> When I log in as someone other than myself the combo box is working >> perfectly, offering only the clients relating to the logged in Team >> Leader (Controller), however, when I log in as myself (iLloyd), the >> combo box is not offering any clients to choose from, although when >> I look at the query behind the row source it looks fine and the >> dataset it produces is the list of all clients as expected, for some >> reason they do not appear within the combo box in form view. >> >> I don't suppose you know what I'm doing wrong do you? >> >> Thanks again for all your help >> >> Ian. >> >> >> "Joan Wild" wrote: >> >>> You'll need to use code to set the rowsource of the combobox in >>> this case. >>> >>> In the Form's open event >>> If CurrentUser() = 'Ian' then >>> Me.cboWhatever.RowSource = "SELECT * FROM MyTable" >>> Else >>> Me.cboWhatever.RowSource = "SELECT * FROM MyTable WHERE >>> [controller] = " & chr(34) & CurrentUser() & chr(34) >>> End If >>> >>> A better solution would be to use the function in the security FAQ >>> that determines if a user is a member of a group >>> http://support.microsoft.com/?id=207793 >>> >>> Then you can use >>> >>> If faq_IsUserInGroup("Admins",CurrentUser) then >>> Me.cboWhatever...etc. >>> >>> >>> -- >>> Joan Wild >>> Microsoft Access MVP >>> >>> Ian Lloyd wrote: >>>> Thanks Joan, your solution works when a controller is logged into >>>> my system, but if I log in as admin I can't see any of the clients >>>> to select from, do you know how I can work around this? >>>> >>>> Ian. >>>> >>>> "Joan Wild" wrote: >>>> >>>>> You'll need to include the Access username in your table of >>>>> clients - i.e. what clients the user is 'attached' to. Perhaps >>>>> your controller field does this, or could do this. >>>>> >>>>> The you change the rowsource of your combo box to >>>>> SELECT [Client] FROM MyTable WHERE [controller] = CurrentUser() >>>>> >>>>> CurrentUser returns the Access logon name. >>>>> >>>>> >>>>> -- >>>>> Joan Wild >>>>> Microsoft Access MVP >>>>> >>>>> Ian Lloyd wrote: >>>>>> Hi, >>>>>> >>>>>> Any ideas how I can restrict the possible selections of a combo >>>>>> box depending on who is signed into the database? For example, >>>>>> in a client database, I have a form to select from a list of >>>>>> clients that the user can amend the details of, I would like to >>>>>> restrict that list to just show the clients under the control of >>>>>> the user signed in. I have another field in my table showing >>>>>> each client by controller. >>>>>> >>>>>> Thanks >>>>>> >>>>>> Ian. Joan, that's worked perfectly, thanks v.much for your help.
Ian. Show quoteHide quote "Joan Wild" wrote: > If CurrentUser() = "iLloyd" OR CurrentUser() = "mClaridge" OR...etc > > If these three users are members of a group (that no one else is a member > of), you'd be better off to use the IsUserInGroup function I pointed to you > earlier. It's more maintainable if you add users or drop others. > > > -- > Joan Wild > Microsoft Access MVP > > Ian Lloyd wrote: > > Hello, > > > > Well it seems that the username is case sensitive and it all works > > perfectly now I've specified my user id correctly, so please ignore > > my previous question. > > > > One more quick question though, I would like the first part of the IF > > statement to depend on the username being either myself or 2 other > > people, I've tried using the line : > > > > If CurrentUser() = "iLloyd" or "mClaridge" or "dPickering" Then > > > > but Access can't execute this code. > > Could you tell me what I should be using please. > > > > Thanks > > > > Ian. > > > > "Ian Lloyd" wrote: > > > >> Hi Joan, > >> > >> Thanks for your help, I've tried copying in your code into the open > >> event of my form, and I believe it is partially working. > >> > >> Here is the code that I have copied in: > >> > >> If CurrentUser() = "iLloyd" Then > >> Me.Combo10.RowSource = "SELECT TblClientMaster.Code, > >> TblClientMaster.Name FROM TblClientMaster ORDER BY > >> TblClientMaster.Name" > >> Else > >> Me.Combo10.RowSource = "SELECT TblClientMaster.Code, > >> TblClientMaster.Name, TblEmployeeMaster.[user ID] FROM > >> TblClientMaster INNER JOIN TblEmployeeMaster ON > >> TblClientMaster.[Team Leader] = TblEmployeeMaster.[Employee Code] > >> WHERE (TblEmployeeMaster.[user ID])=CurrentUser() ORDER BY > >> TblClientMaster.Name" End If > >> > >> When I log in as someone other than myself the combo box is working > >> perfectly, offering only the clients relating to the logged in Team > >> Leader (Controller), however, when I log in as myself (iLloyd), the > >> combo box is not offering any clients to choose from, although when > >> I look at the query behind the row source it looks fine and the > >> dataset it produces is the list of all clients as expected, for some > >> reason they do not appear within the combo box in form view. > >> > >> I don't suppose you know what I'm doing wrong do you? > >> > >> Thanks again for all your help > >> > >> Ian. > >> > >> > >> "Joan Wild" wrote: > >> > >>> You'll need to use code to set the rowsource of the combobox in > >>> this case. > >>> > >>> In the Form's open event > >>> If CurrentUser() = 'Ian' then > >>> Me.cboWhatever.RowSource = "SELECT * FROM MyTable" > >>> Else > >>> Me.cboWhatever.RowSource = "SELECT * FROM MyTable WHERE > >>> [controller] = " & chr(34) & CurrentUser() & chr(34) > >>> End If > >>> > >>> A better solution would be to use the function in the security FAQ > >>> that determines if a user is a member of a group > >>> http://support.microsoft.com/?id=207793 > >>> > >>> Then you can use > >>> > >>> If faq_IsUserInGroup("Admins",CurrentUser) then > >>> Me.cboWhatever...etc. > >>> > >>> > >>> -- > >>> Joan Wild > >>> Microsoft Access MVP > >>> > >>> Ian Lloyd wrote: > >>>> Thanks Joan, your solution works when a controller is logged into > >>>> my system, but if I log in as admin I can't see any of the clients > >>>> to select from, do you know how I can work around this? > >>>> > >>>> Ian. > >>>> > >>>> "Joan Wild" wrote: > >>>> > >>>>> You'll need to include the Access username in your table of > >>>>> clients - i.e. what clients the user is 'attached' to. Perhaps > >>>>> your controller field does this, or could do this. > >>>>> > >>>>> The you change the rowsource of your combo box to > >>>>> SELECT [Client] FROM MyTable WHERE [controller] = CurrentUser() > >>>>> > >>>>> CurrentUser returns the Access logon name. > >>>>> > >>>>> > >>>>> -- > >>>>> Joan Wild > >>>>> Microsoft Access MVP > >>>>> > >>>>> Ian Lloyd wrote: > >>>>>> Hi, > >>>>>> > >>>>>> Any ideas how I can restrict the possible selections of a combo > >>>>>> box depending on who is signed into the database? For example, > >>>>>> in a client database, I have a form to select from a list of > >>>>>> clients that the user can amend the details of, I would like to > >>>>>> restrict that list to just show the clients under the control of > >>>>>> the user signed in. I have another field in my table showing > >>>>>> each client by controller. > >>>>>> > >>>>>> Thanks > >>>>>> > >>>>>> Ian. > > >
User level security-- do not have necessary permissions
mapped network drive and security error Tab Change Passwords Password for opening Report user without admin privilleges was able to join his computer to do Secure back end database Open an Access Database from Another UnHIDE a tbl look for VBA codes to make Tables and Quries to be READ ONLY reports don't print boxes or check marks. |
|||||||||||||||||||||||