Show function in preproc of protected field

Discussions about CSEntry
Post Reply
Keith Tomlin
Posts: 56
Joined: March 23rd, 2014, 9:30 am

Show function in preproc of protected field

Post by Keith Tomlin »

Hi there

I have a protected field as the first field on a multiple-occurring record. At the preproc of the field I use the show function to give a list of names, from which the value of the protected field is chosen. This works fine when the tick of the show function is clicked, but if the red cross or the escape button are used, I get a message saying that the value for the field is out of range, which leads to a "clean-up" and the data entry application shutting down. I've got around this a bit by adding some logic saying that if the value of the show function is 0, I should return to the previous field. My problem is that that starting a new occurrence - and therefore coming to this protected field - can be triggered by a number of fields in the previous occurrence. So my question is - is there a way of not triggering the error messages when the value returned by the show function is 0; or is there a way of saying in logic "if show=0, return to the previous field (ie most recently left field) in the previous occurrence", without having to specify the name of the previous field?

Many thanks in advance for your help.

All the best

Keith
Gregory Martin
Posts: 1947
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Show function in preproc of protected field

Post by Gregory Martin »

There is no easy way to know what the previously entered field was, which you could then reenter. There is, however, an undocumented function, On_Focus, that gets called on every field of your questionnaire. You could store the name of each field entered into a temporary variable and then use that to achieve something close to what you want to do. See attached, and the following code:
PROC GLOBAL

alpha (100) thisField, lastField;

function On_Focus()

    lastField = thisField;
    thisField =
getsymbol();

end;

PROC VALUE_1

preproc

    
if curocc() > 1 and accept("Continue on...?","Yes","No") = 2 then
        
reenter maketext("%s(%d)",strip(lastField),curocc() - 1);
    
endif;
You do not have the required permissions to view the files attached to this post.
Post Reply