Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show Window

Status
Not open for further replies.

Chance1234

IS-IT--Management
Jul 25, 2001
7,871
US
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
 
For the use, this works (I got it from a post here)

Public Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long


Public Function fOSUserName() As String
' Returns the network login name
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 = &quot;&quot;
End If
End Function

I don't think you can call the ShowWindow directly. You;ll have to do something :retval = ShowWindow(Form1.hWnd, SW_SHOW) ' display the window if it's hidden Tyrone Lumley
augerinn@gte.net
 
worked out what it was you have to set the form property pop up to yes and drop the do command
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top