Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

Applies to

Form Object

Report Object

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

expression.Hwnd

expression Required. An expression that returns one of the objects in the Applies To list.

Remarks

This property is available only by using a macro or Visual Basic for Applications (VBA) code.

You can use this property in VBA code 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.

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

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×