Click to See Complete Forum and Search --> : Popup Menu Problem


Rippin
January 17th, 2000, 04:17 PM
Here's the problem:
I have a form that has a listview that displays a recordset. The user can double-click on a specific listitem which brings up another form to edit the data. They can also right-click on the listview and choose Edit from a popup menu. Either way, the same popup dialog window is shown. The problem is, if the user accesses the new form via the popup menu, I can not display a popup menu on the new form, however if they simply double-click on the item, when the new form is loaded, the popup menu is displayed just fine.

Does anyone know of a work-around for this or why it is happening?

Bruno
January 17th, 2000, 06:42 PM
One solution is here:
http://www.vb2themax.com/Item.asp?PageID=BugBank&ID=3

but I think this is better:
Do not execute action (show form) in menu_Click event.
Instead, just return value to the function which called PopupMenu and execute action in that caller function:


' Form1 code
option Explicit

private Sub Form_MouseUp(Button as Integer, Shift as Integer, X as Single, Y as Single)
Dim strSelection as string
If Button = vbRightButton then
Load frmpopups
' you can check/uncheck menu items here or in frmPopups
' show popup menu
PopupMenu frmpopups.mnuPop
' get selection
strSelection = frmpopups.Selection
Unload frmpopups
'
' execute action here
Select Case strSelection
Case "Edit"
' frmEdit.Show vbModal
Case "Delete", "Refresh"
' do something
End Select
End If
End Sub
'----------------------------------------------
' frmPopups Form
' Contains popup menu for Listview
' mnuPop
' mnuEdit
' mnuDelete
' mnuRefresh
option Explicit
private mSelection as string
private Sub Form_Load()
mSelection = ""
End Sub
public property get Selection() as string
Selection = mSelection
End property
private Sub mnuDelete_Click()
mSelection = "Delete"
End Sub
private Sub mnuEdit_Click()
mSelection = "Edit"
End Sub
private Sub mnuRefresh_Click()
mSelection = "Refresh"
End Sub