Hi Brett
This works for me :
' menu as follows :
Begin VB.Menu mnuAddDatesMaster
Caption = "Standard Date Expressions"
Visible = 0 'False
Begin VB.Menu mnuAddDates
Caption = "Please choose a date expression"
Index = 1
End
' part of a function called from Form_load to create the menu once only
localRS.Open "SELECT DESCRIPTION, START_YEAR, END_YEAR FROM
DATE_EXPRESSIONS_TBL ORDER BY DESCRIPTION", localCN
iIndex = 2
Do Until localRS.EOF
Load mnuAddDates(iIndex)
mnuAddDates(iIndex).Caption = localRS!Description & " (" &
localRS!start_year & "-" & localRS!start_year & ")"
iIndex = iIndex + 1
localRS.MoveNext
Loop
localRS.Close
localCN.Close
Set localRS = Nothing
Set localCN = Nothing
' menu handling code
Private Sub mnuAddDates_Click(Index As Integer)
Dim iInsertionPoint As Integer
Dim sAdd As String
Dim iPos As Integer
iInsertionPoint = txtDates.SelStart
iPos = InStr(mnuAddDates(Index).Caption, "(")
If iPos = 0 Then
sAdd = mnuAddDates(Index).Caption
Else
sAdd = Left(mnuAddDates(Index).Caption, iPos)
End If
If iInsertionPoint = 0 Then
txtDates = txtDates & " " & sAdd & " "
Else
txtDates = Left(txtDates, iInsertionPoint - 1) & " " & sAdd & " " &
Mid(txtDates, iInsertionPoint)
End If
End Sub
HTH!
-----Original Message-----
From: Brett Arthur [mailto:brett@d...]
Sent: 16 February 2001 15:07
To: professional vb
Subject: [pro_vb] Adding menu's at runtime
Hi,
I would like to dynamically add menus at runtime to an exiting menubar on
a form. Does anyone have example code of how to do this.
Thanks in advance,
Brett