Every so often, a developer might need to check or set the status of a form level menu item. Say, for instance, the goal would be to make sure that the "Add Item" menu item of the Sales Transaction Entry Options menu was checked.
From a global procedure - your trigger handling script most likely - you enter the following Dexterity code:
check menu Options of form SOP_Entry,1;When you try to compile this, the compiler will fail with the errors:
Unknown Identifier 'Options'. Type incompatability 'check requires a list field or menu'.
In the past, what I've seen developers do is make an alternate form just so that they can make a new form level function or field level change script that does have access to the menu item. While that would work, it obviously isn't the best solution if you don't have to modify the form for other reasons.
The code below is what I have referenced in a newsgroup post as "the menu reference trick" and the technique that I used for the Additem.cnk way back when.
local reference m; {Get the reference to the menu - this is the 'trick'}assign m as reference to menu Options of form SOP_Entry; {Look if the 'Add Item' is marked or not by dereferencing it. If not marked, give a warning and then set it. Yes the check is redundant but this exampleshows we have full access to the form level menu item.}if checkedmenu(menu(m),1) = false then warning "The 'Add Item' menu item is not checked."; {Next check the first menu item in the list - Add Item.} check menu(m),1;end if;
local reference m;
{Get the reference to the menu - this is the 'trick'}assign m as reference to menu Options of form SOP_Entry;
{Look if the 'Add Item' is marked or not by dereferencing it. If not marked, give a warning and then set it. Yes the check is redundant but this exampleshows we have full access to the form level menu item.}if checkedmenu(menu(m),1) = false then warning "The 'Add Item' menu item is not checked."; {Next check the first menu item in the list - Add Item.} check menu(m),1;end if;
This method will also work for 3rd party menu items provided you use the code within the execute() function.
Best Regards,PatrickDeveloper Support
// Copyright © Microsoft Corporation. All Rights Reserved.// This code released under the terms of the // Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)
Patrick,
This is a great article! I wondered a few times how to get this done without duplicating a form, but I guess I did not think of setting up a reference to the object. I assume, this can also be done for DDLs, list boxes, etc.
Best regards,
MG.-
Mariano Gomez, MVP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com
Yes you can set up a reference to whatever you like. However most of the time you don't need to because you can just reference a field directly in your global script. Of course using references to fields, windows, etc does have other practical uses.
Hi Patrick,
This is indeed a terrific input. I had done the same thing using VBA, but had no idea how to do from Dex.
Thank you so much for this informative article.
Thanks
Vaidy
www.vaidy-dyngp.com
PLEASE READ BEFORE POSTING
Please only post comments relating to the topic of this page.
If you wish to ask a technical question, please use the links in the links section (scroll down, on right hand side) to ask on the Newsgroups or Forums. If you ask on the Newsgroups or Forums, others in the community can respond and the answers are available for everyone in the future.