Attached is some code that I use for a custom shortcut menu that I use on
most of my forms. I call the subroutine when my Splash screen loads, and
then use the click event of a control on my form (usually a label in the
upper left corner of the form) to display the shorcut menu, using:
CommandBars("MyFormMenu").ShowPopup
What you will need to do is change the references to fnCloseForm to a new
function that you write.
You can then declare a form variable (Dim frm as Form) and set it to the
screen.activeform. Once you have done that, you can open the new form and
transfer values from the frm.text1 or other controls to controls on the newly
opened form.
HTH
Dale
Public Sub MenuForm()
Dim cbr As Object
Dim cbrButton As Object
If CmdBarExists("MyFormMenu") Then Exit Sub
On Error GoTo FormMenuError
DoCmd.Hourglass True
Set cbr = CommandBars.Add("MyFormMenu", BarPopup, , True)
With cbr
Set cbrButton = cbr.Controls.Add(ControlButton, , , , True)
With cbrButton
.Caption = "&Close"
.Tag = "Close"
.OnAction = "=fnCloseForm()"
End With
Set cbrButton = cbr.Controls.Add(ControlButton, , , , True)
With cbrButton
.Caption = "&Quit"
.Tag = "Quit"
.OnAction = "=fnQuit()"
End With
End With
DoCmd.Hourglass False
Exit Sub
FormMenuError:
MsgBox "ReportMenu error" & vbCrLf
End Sub
Public Function fnCloseForm()
Dim frm As Form
Set frm = Screen.ActiveForm
On Error Resume Next
frm.AllowClose = True
DoCmd.Close acForm, frm.Name
End Function
Public Function CmdBarExists(BarName As String) As Boolean
Dim intControls
On Error Resume Next
intControls = CommandBars(BarName).Controls.Count
If Err.Number = 0 Then
CmdBarExists = True
Else
CmdBarExists = False
End If
End Function