Solved How can I hide/unhide item in combo box as per user login (1 Viewer)

Kamayo Ako

Member
Local time
Today, 23:21
Joined
May 23, 2022
Messages
89
Have a good day to all!!!

I just want to ask your favor on how to hide/unhide item in the combo box as per user login.

Combo Box item List

1. Remove Stock - This will show only for user - A
2. Manufactured Parts - This will show only for user - A
3. Move to Warehouse - This will show only for user - B

Thank you so much in advance for your support.

Kamayo Ako
 

Attachments

  • COMBO BOX ISSUE.png
    COMBO BOX ISSUE.png
    22.7 KB · Views: 117

MajP

You've got your good things, and you've got mine.
Local time
Today, 16:21
Joined
May 21, 2018
Messages
8,527
Is it really just 2 types? If not it requires a second table.

tblTransactionTypes
-- TransactionName (Remove stock,...)
-- Group (A,B)

Data would be
Remove StockA
Manufacture PartsA
Move To WarehouseB

How you determine permissions depends on how you are set up. I save this in a tempvar when the user logs in. You may save in a table, or you save the user login and use a dlookup to get the permission.

Code:
Public Function GetPermission() as string
  .. depending on how you are set up some way to return the user permissions.
end Function

On the forms on load event

Code:
Public sub Form_Load
  dim strSql as string
  dim PermissionGroup as string
  permissionGroup = getPermission

  strSql = "Select * from tblTransactionTypes where Group = '" & permissionGroup & "'"
  me.cmboTransactionType.rowsource = strSql
end function
 
Last edited:

MajP

You've got your good things, and you've got mine.
Local time
Today, 16:21
Joined
May 21, 2018
Messages
8,527
If your groups are much more complicated and the choices are greater You may need values in your table like

tblTransactionTypes
A Remove Stock
A ManufactureParts
B MoveToWareHouse
C Remove Stock
C MoveToWareHouse
C Ship Back
D Remove Stock
D Ship Back
 

Kamayo Ako

Member
Local time
Today, 23:21
Joined
May 23, 2022
Messages
89
Is it really just 2 types? If not it requires a second table.

tblTransactionTypes
-- TransactionName (Remove stock,...)
-- Group (A,B)

Data would be
Remove StockA
Manufacture PartsA
Move To WarehouseA

How you determine permissions depends on how you are set up. I save this in a tempvar when the user logs in. You may save in a table, or you save the user login and use a dlookup to get the permission.

Code:
Public Function GetPermission() as string
  .. depending on how you are set up some way to return the user permissions.
end Function

On the forms on load event

Code:
Public sub Form_Load
  dim strSql as string
  dim PermissionGroup as string
  permissionGroup = getPermission

  strSql = "Select * from tblTransactionTypes where Group = '" & permissionGroup & "'"
  me.cmboTransactionType.rowsource = strSql
end function
Thank you for your response sir.

Actually sir im using user Role to manage that permission.
User role
- Administrator
- Production
- User

I'm using Global User role

Private Sub Form_Load()

txtUser.Value = strUser
txtRole.Value = strRole

Select Case strRole


Case "Administrator"


Case "Production"

Case "Warehouse"


Case Else

End Select


End Sub
 

Kamayo Ako

Member
Local time
Today, 23:21
Joined
May 23, 2022
Messages
89
Thank you for your response sir.

Actually sir im using user Role to manage that permission.
User role
- Administrator
- Production
- User

I'm using Global User role

Private Sub Form_Load()

txtUser.Value = strUser
txtRole.Value = strRole

Select Case strRole


Case "Administrator"


Case "Production"

Case "Warehouse"


Case Else

End Select


End Sub
 

Attachments

  • PRODUCTION INVENTORY.accdb
    2.3 MB · Views: 154

MajP

You've got your good things, and you've got mine.
Local time
Today, 16:21
Joined
May 21, 2018
Messages
8,527
Code:
Private Sub Form_Load()

  Dim strSql as string
  dim Role as string

  txtUser.Value = strUser
  txtRole.Value = strRole

  strSql = "Select * from tblRoles_TransactionTypes where Role = '" & strRole & "'"
  me.cmboTransactiontype.rowsource = strSql
End Sub
Since you have three roles you need to do something like this. And since you are storing the TransactionTypeID you store that. This is really a junction table so I will rename

tblRoles_TransActionTypes

RoleTransctionTypeID_FK
Administrator1
Administrator2
Administrator3
Production1
Production2
....
 

CarlettoFed

Member
Local time
Today, 22:21
Joined
Jun 10, 2020
Messages
119
Surely first of all you have to review the database structure as it is not correct either from the point of view of Field Properties or from that of Normalization.
 

Kamayo Ako

Member
Local time
Today, 23:21
Joined
May 23, 2022
Messages
89
Code:
Private Sub Form_Load()

  Dim strSql as string
  dim Role as string

  txtUser.Value = strUser
  txtRole.Value = strRole

  strSql = "Select * from tblRoles_TransactionTypes where Role = '" & strRole & "'"
  me.cmboTransactiontype.rowsource = strSql
End Sub
Since you have three roles you need to do something like this. And since you are storing the TransactionTypeID you store that. This is really a junction table so I will rename

tblRoles_TransActionTypes

RoleTransctionTypeID_FK
Administrator1
Administrator2
Administrator3
Production1
Production2
....
Thank you so much...
If your groups are much more complicated and the choices are greater You may need values in your table like

tblTransactionTypes
A Remove Stock
A ManufactureParts
B MoveToWareHouse
C Remove Stock
C MoveToWareHouse
C Ship Back
D Remove Stock
D Ship Back
thank you so much sir
 

Kamayo Ako

Member
Local time
Today, 23:21
Joined
May 23, 2022
Messages
89
Code:
Private Sub Form_Load()

  Dim strSql as string
  dim Role as string

  txtUser.Value = strUser
  txtRole.Value = strRole

  strSql = "Select * from tblRoles_TransactionTypes where Role = '" & strRole & "'"
  me.cmboTransactiontype.rowsource = strSql
End Sub
Since you have three roles you need to do something like this. And since you are storing the TransactionTypeID you store that. This is really a junction table so I will rename

tblRoles_TransActionTypes

RoleTransctionTypeID_FK
Administrator1
Administrator2
Administrator3
Production1
Production2
....
Thank you so much sir. now it's working... I just tweaks some but your code really matters. And thank you to all...

1655039945627.png
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 16:21
Joined
May 21, 2018
Messages
8,527
As mentioned your table design needs a lot of work. Do you want help in that area?
 

Kamayo Ako

Member
Local time
Today, 23:21
Joined
May 23, 2022
Messages
89
As mentioned your table design needs a lot of work. Do you want help in that area?
If you have a spare time sir. Yes.. its my pleasure. Actually it's working already but i believe that you have a more effecient way.
 

Users who are viewing this thread

Top Bottom