It's not clear what you want but code below should get you started. Notice that REPLACE ALL and SCAN FOR are used instead of DO WHILE. It makes code simpler.
SELECT AsDoc
REPLACE ALL AsDoc.ad_command with 'do txt with '+ TRANSFORM(RECNO())
set order to menu
On BAR 6 OF Update ACTIVATE POPUP Documents
Define POPUP Documents MARGIN
DEFINE BAR 1 OF Documents PROMPT "\<View Documents"
DEFINE BAR 2 OF Documents PROMPT "\<Key Documents"
DEFINE BAR 3 OF Documents PROMPT "\<Other Documents"
ON BAR 2 OF Documents ACTIVATE POPUP KeyDocs
Define POPUP KeyDocs MARGIN
i=1
SCAN FOR AsDoc.ad_menu='D'
DEFINE BAR i of KeyDocs PROMPT (ALLTRIM(AsDoc.ad_label))
comm = alltrim(AsDoc.ad_command)
ON SELECTION BAR i of KeyDocs &comm
i=i+1
ENDSCAN
use
>Hi all
>
>Attached is an Addmenu program. I need to show some user defined docs under a sub menu i.e. Update – Documents – Key Documents
>
>I can get them to appear if I type like this only: Update – Documents
>
>On BAR 6 OF Update ACTIVATE POPUP mz1
>
>Define POPUP mz1
>
>Then my user defined documents appear under the menu Update - Documents.
>
>But I need them to appear under the menu Update – Documents – Key Documents
>
>Here is the code I am using below:
>
<snip>
--sb--