Article ID: 148833
Article Last Modified on 1/19/2007
Name: Menu
RowSourceType: Value List
RowSource: String1;String2;String3;String4
AfterUpdate: =ItemSelected([Menu])
Left: 0 in
Top: 0 in
FontName: System
FontSize: 8
FontWeight: Bold
NOTE: Specify the menu strings in the RowSource property. Separate
the string values with a semicolon (;).
Pop-up Menu Form
---------------------------------------------------
ScrollBars: Neither
RecordSelectors: No
NavigationButtons No
PopUp: Yes
Width: <Width of the list box control>
Section Properties
----------------------------------------------------
Height: <Height of the list box control>
' NOTE: Some of the following Windows API functions may be
' defined in an existing Microsoft Access library. If so, the new
' declarations would cause a duplication procedure name error. If
' this error occurs, remove the offending declare statement from
' your code or convert the declaration to a comment.
Option Explicit
Type POINTAPI
x As Long
y As Long
End Type
Global Const GWL_STYLE = (-16)
Global Const WS_DLGFRAME = &H400000
Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) _
As Long
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong _
As Long) As Long
Function ShowPopup ()
Dim coord As POINTAPI
Dim attr&
GetCursorPos coord
DoCmd.OpenForm "Pop-up Menu Form"
attr& = GetWindowLong(Forms![Pop-up Menu Form].hWnd, GWL_STYLE)
attr& = SetWindowLong(Forms![Pop-up Menu Form].hWnd, GWL_STYLE, _
attr& And Not WS_DLGFRAME)
DoCmd.MoveSize (coord.x * 14), (coord.y * 14), , 1100
End Function
Function ItemSelected (WhichItem As String)
DoCmd.Close
MsgBox "The selected item was " & Trim(WhichItem)
End Function
=ShowPopup()Keywords: kbhowto kbprogramming KB148833