Log in form data usable globally

Rob Ross

Registered User.
Local time
Yesterday, 22:10
Joined
May 24, 2012
Messages
28
I'm still trying to get my mind around the VBA coding but here is my question. I have a log on form that verifies a user based on a user name and password table. How can I save the log in name for global use in other forms - i.e. to recheck permissions based on admin or not so that an administrative form will open if they have rights. I know it should be a global variable instead of private but not sure how to do it.

I hope this makes since. I was using this type of statement to open a normal form or an admin form but reconfigured database so everyone opens frmUser and added a button for admin to select to open special form.

Dim iEmp As Long
iEmp = Me.cboEmployee
DoCmd.close acForm, "frmStartUp", acSaveNo
If Nz(DLookup("Admin", "Technicians", "[ID]=" & iEmp), 0) Then
DoCmd.OpenForm "frmAdm"
Else
DoCmd.OpenForm "frmUser"
End If
 
How can I save the log in name for global use in other forms - i.e. to recheck permissions based on admin or not so that an administrative form will open if they have rights. I know it should be a global variable instead of private but not sure how to do it.

The way I provided this capability is to create instances of class objects and allow the values to be encapsulated (contained by) the objects.

I create instances of said classes in VBA modules, organization / grouping logically the various objects which need to be created into a specific VBA module for the portion of the application those objects logically belong to. So in the case of the ObjAuthTbl object, I create that in the module assocuiated with the Main part of the program since it is needed throughout the application.

Code:
REM Part of modmain_bootstrap

'Order of creation of these objects should be the same order they are used in
'Form_main \ Form_Load()
Public ObjAppSettings As New clsObjAppSettings
Public ObjBEDBConnection As New clsObjBEDBConnection
[COLOR=Blue][B]Public ObjAuthTbl As New clsObjAuthTbl[/B][/COLOR]
Public ObjMSysObjectsTbl As New clsObjMSysObjectsTbl

'Next create the cfg objects, starting with the server's instance
Public ObjSrvCfgTbl As New clsObjSrvCfgTbl
Public ObjCfgTbl As New clsObjCfgTbl
Then I may reference ObjAuthTbl throughout the application. That contains the userid, username, permissions for the user, etc... So simple checks of the ObjAuthTbl object are used to grant permissions throughout the application.

Code:
REM Part of Form_partsedit Form_Load event

  'Configure UI based on auth permmask
  'Change Records
  If [B][COLOR=Blue]ObjAuthTbl.IsAuthChangeRecords()[/COLOR][/B] Then
    Me.btnCommit.Enabled = True
  Else
    Me.btnCommit.Enabled = False
  End If
 

Users who are viewing this thread

Back
Top Bottom