Private Sub EisVBAForm_FormInitialize()
'Set SYS Level to 1 and User to 0
'Elite setups give access if User Level is higher than SYS
'so we're starting with denying access
'Then evaluating their actual access levels
SysLevel = 1
UserLevel = 0
'Get SYS Access Level
strSQL = "SELECT u85 FROM uaccess WHERE uname='SYS'"
Set rsUaccess = DB.OpenResults(strSQL)
If rsUaccess.Count = 0 Then
MsgBox "User Access Error." & vbCrLf & "Contact System Administrator", vbOKOnly + vbExclamation, "User Access Error"
Else
SysLevel = rsUaccess.Value(0)
'Get User Access Level
strSQL = "SELECT u85 FROM uaccess WHERE uname='" & Trim(UserID) & "'"
Set rsUaccess = DB.OpenResults(strSQL)
If rsUaccess.Count > 0 Then
UserLevel = rsUaccess.Value(0)
End If
'Compare the two, if User is lower than Sys, Hide a control on the form
If UserLevel < SysLevel Then
cmdDistProf.Visible = False
End If
End If
Set rsUaccess = Nothing
End Sub
Showing posts with label vba. Show all posts
Showing posts with label vba. Show all posts
Thursday, April 14, 2011
VBA - Controlling Form Appearance via User Access
We've added some custom functionality to several of our Elite forms recently using Visual Basic for Applications (VBA). As with many things Elite, there's more than one way to accomplish the goal. In this case, we only wanted certain users to have access to the custom functionality. The popular method that is included in your Elite documentation would be to set the users up in a group and make the VBA changes just for that group. I didn't particularly want to go down that route for several reasons, so what I settled on was controlling the visibility of the custom items via a user access setting. In the case below, it is u85: the ability to access Queues in Reports & Queues. The custom control is set to visible on the form, and if the user does not have access to queues, then the control is hidden.
Friday, January 29, 2010
Time Load VBA Scripting Example
One of the neat things about Enterprise is that it is customizable with VBA scripting. One of the uses I've found for this is to change the default checkboxes in many of the Enterprise screens to match how we do things. For instance, when our users need to manually upload time using Time Load, they have to select Expanded Line Format 2 and Workstation from the options. Rather than the users having to manually select these (and risk errors by choosing the wrong option), we can use VBA to default to these two choices. The code is shown below for this particular change.
Private Sub eisvbaform_forminitialize() Me.gpbInput0 = False Me.gpbInput4 = True Me.optDos = True Me.optUnix = False End SubWhen making VBA changes, I usually test at my user level first and then at the firm level. To make the changes at the firm level, when logging in, choose the Advanced option and the Select different user for form and VBA changes option. Browse to the form you want to edit and choose VBA Editor from the Design menu. Making these types of changes are simple, and can save administrators headaches caused by incorrect user input.
Subscribe to:
Posts (Atom)

