PDA

View Full Version : Solved: Only run code if staffnumber is equal to xxxxx



khalid79m
02-09-2010, 04:40 AM
Option Explicit
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If (lngX > 0) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function
Private Sub OpenFile()
If fOSUserName = "04816434" Or "04876414" Then

Dim Response As Integer

Response = MsgBox(prompt:="Select 'AdminMode'.", Buttons:=vbYesNo)

If Response = vbYes Then
Run "AdminMode"
Run "RestoreToolbars"
Else
Run "C_Int_DynamicDropDowns"
Run "RemoveToolbars"
Run "LiveMode"
End If

Else

Run "C_Int_DynamicDropDowns"
Run "RemoveToolbars"
Run "LiveMode"

End If
End Sub


I have the following code which gets me the user id (staffnumber). But I want the above code to run if the user id is equal to "04816434" Or "04876414" . This currentley runs the enitre code no matter who the user is ,... can anyone help .. i bet im doing a schoolboy error

GTO
02-09-2010, 05:43 AM
try


If fOSUserName = "04816434" Or fOSUserName = "04876414" Then

khalid79m
02-15-2010, 09:39 AM
gto your the man.. thanks