Here's a quick and (hopefully) easy question.
In various forms, when I need the user to select a record from another table through a lookup, I do the following if there is no particular processing (no need to call a function on the LookUp form, the LookUp form is a regular tabular form with the usual OK/Cancel buttons, etc.)
// Assuming we have a MyRecord : Record ("My Record") variable
IF FORM.RUNMODAL(FORM::"My Lookup Form", MyRecord) = ACTION::LookupOK THEN BEGIN
// Do stuff with the selected record
END;
I found our partner usually did the same thing in another way, for the same case (no particular processing).
// Assuming we have a MyRecord : Record ("My Record") variable and a MyLookupForm : Form ("My Lookup Form") variable.
MyLookupForm.SETTABLEVIEW(MyRecord);
MyLookupForm.EDITABLE(FALSE); // Optional - only needed if the LookupForm is also used in another context to modify data
MyLookupForm.LOOKUPMODE := TRUE;
IF MyLookupForm.RUNMODAL = ACTION::LookupOK THEN BEGIN
MyLookupForm.GETRECORD(MyRecord);
// Do stuff with the selected record
END;
If all I need a lookup button to do is getting a record without any unusual processing, it seems to me that declaring a Form variable, initializing it, etc. is overkill. Under this hypothesis (i.e. I do not otherwise need the Form variable), are the two above code snippets equivalent?
I looked on mibuso and elsewhere on the web, but couldn't find a definitive answer to my question. In fact, everybody seems to be recommending the second method as the general solution to "lookup a record in another table", but I find it unnecessarily "complex" for the simple case, so I'm wondering if there might be a subtle difference I couldn't find about.
Thanks!