Options

Looks up table but doesn't pull back value

jfrizellejfrizelle Member Posts: 5
Hi,

Why does my Postcode lookup on my customer table display the list of postcodes fine, but then not retrieve anything? I highlight the record I want and click OK, but back on the customer table the Postcode field remains unchanged.... Yet on the Customer Card, it does pull back the value. :-k

I've noticed that there are (pre-defined?) functions in the OnValidate and OnLookup triggers for the Postcode field

PostCode.ValidatePostCode(City,"Post Code");
and
PostCode.LookUpPostCode(City,"Post Code",TRUE);

When I comment out these lines in the table, it retrieves the code and populates the field.

Strange. I know the users will be accessing the form, not the table, so it's not a big deal, but I'm puzzled by this.

TIA!
J.

Comments

  • Options
    DenSterDenSter Member Posts: 8,304
    OnLookup code in the form takes precedent over what is in the table, which in turn takes precedent over the table relation. Whatever you did to your relation, you will have to program in those lookup functions.
  • Options
    nelsonnelson Member Posts: 107
    The behaviour of the OnLookup triggers for Tables was changed somewhere between versions 2.50 -> 3.x
    I'm not sure which version changed it but it used to work the same at Table level and at Form level.
    Now it only works at Form level and damn me if I know why...

    The upshot is that before we could use the following code in OnLookup:
    Field - OnLookup
    some code, bla bla bla
    Field := 'Some Value';
    
    And this would run the field's OnValidate trigger.

    Now we have to do it this way to get the same effect:
    Field - OnLookup
    some code, bla bla bla
    VALIDATE(Field,'Some Value');
    

    I really don't like this behaviour as it causes the field value to be validated before the user even leaves the field.
    That's not standard behaviour if you have no code OnLookup and the system uses the TableRelation to provide a lookup to the user. In this case, the user will be able to retrieve the value, see it being copied to the field but only validated when he tries to leave the field.

    On the other hand, if you change a Post Code in the Customer Card (which is a field where the lookup is provided through code), you will see that the system will fill in City and County as soon as you press OK on the Lookup form - so before exiting the field.

    I'm not sure why they changed it and I'm not even sure if the change was documented (this is of course my fault for not searching all the "Changes" docs).
    But anyway, I would call this a bug. :whistle:
    Unless someone knows better.
    Nelson Alberto
Sign In or Register to comment.