Edit

Share via


Form.hWnd property (Access)

Use the hWnd property to determine the handle (a unique Long Integer value) assigned by Windows to the current window. Read/write Long.

Syntax

expression.hWnd

expression A variable that represents a Form object.

Remarks

Use this property in Visual Basic when making calls to Windows application programming interface (API) functions or other external routines that require the hWnd property as an argument. Many Windows functions require the hWnd property value of the current window as one of the arguments.

Note

Because the value of this property can change while a program is running, don't store the hWnd property value in a public variable.

Example

The following example uses the hWnd property with the Windows API IsZoomed function to determine if a window is maximized.

' Enter on single line in Declarations section of Module window. 
Declare Function IsZoomed Lib "user32" (ByVal hWnd As Long) As Long 
 
Sub Form_Activate() 
 Dim intWindowHandle As Long 
 intWindowHandle = Screen.ActiveForm.hWnd 
 If Not IsZoomed(intWindowHandle) Then 
 DoCmd.Maximize 
 End If 
End Sub

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.