Chance1234
IS-IT--Management
Can anyone tell me why this doesnt work ?
Private Declare Function ShowWindow Lib "user32" _
(ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, _
nSize As Long) As Long
Private Sub Form_Open(Cancel As Integer)
Me.Caption = WhoAmI
Call ShowWindow(hWndAccessApp, SW_HIDE)
DoCmd.OpenForm "frmmaindata", windowmode:=acDialog
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim lngret As Long
lngret = ShowWindow(hWndAccessApp, SW_MAXIMIZE)
End Sub
Private Function WhoAmI() As String
Dim lngret As Long
Dim lpBuffer As String
Dim nSize As Long
lpBuffer = String$(255, 0)
nSize = Len(lpBuffer)
lngret = GetUserName(lpBuffer, nSize)
If lngret = 0 Then
lpBuffer = String$(nSize, 0)
lngret = GetUserName(lpBuffer, nSize)
End If
WhoAmI = Left(lpBuffer, nSize - 1)
End Function
Private Declare Function ShowWindow Lib "user32" _
(ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, _
nSize As Long) As Long
Private Sub Form_Open(Cancel As Integer)
Me.Caption = WhoAmI
Call ShowWindow(hWndAccessApp, SW_HIDE)
DoCmd.OpenForm "frmmaindata", windowmode:=acDialog
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim lngret As Long
lngret = ShowWindow(hWndAccessApp, SW_MAXIMIZE)
End Sub
Private Function WhoAmI() As String
Dim lngret As Long
Dim lpBuffer As String
Dim nSize As Long
lpBuffer = String$(255, 0)
nSize = Len(lpBuffer)
lngret = GetUserName(lpBuffer, nSize)
If lngret = 0 Then
lpBuffer = String$(nSize, 0)
lngret = GetUserName(lpBuffer, nSize)
End If
WhoAmI = Left(lpBuffer, nSize - 1)
End Function