OnLookup - save value

Fisherman
Fisherman Member Posts: 456
I'm really having trouble with something that seems like it would be easy.

I'm using OnLookup() in a table to allow the user to select a value, and I'm trying to store the result of that value through Validate.

When I step through the debugger, I see that the value was captured, and can even see the value in Rec, but once the validate trigger is finished, the table hasn't been updated.

Has anyone else seen this before? Is this a common problem that I'm just missing?

Comments

  • Savatage
    Savatage Member Posts: 7,142
    are you using code or the properties of the field to lookup? If code can you post it?
  • bylle
    bylle Member Posts: 47
    If you are using code - have you then tried using a MODIFY after setting the field value?
  • DenSter
    DenSter Member Posts: 8,307
    MODIFY does not run the field validation, it writes the whole record to the database. To validate a field in code, you use:
    TheRecordVariable.VALIDATE(TheField,Value);
    
    My guess is that this is the OnLookup trigger of a form, and you'll need to add the VALIDATE into the field to make the OnValidate code run.
  • bylle
    bylle Member Posts: 47
    Yes, I know that MODIFY does not trigger the Validation of a field.

    - but if the changes has not been stored, it could be an idea to first validate the field and then afterwards do a modify ;-)
  • Fisherman
    Fisherman Member Posts: 456
    Thanks, guys.

    I was trying to raise a custom STRMENU dialog from the lookup function for the field, and save the integer result to that field.

    Kind of like an OptionString, only I couldn't use an Option for this field because I'm trying to create a higher-level abstraction for generalization purposes, so I'm dynamically creating the OptionString and showing it in a STRMENU, and then storing the result.

    I ended up solving it by moving the code into the Form. I just couldn't get it to modify the field value when the code was inside the validate trigger for that field.