[solved] Avoid double entry

SV_WillSV_Will Member Posts: 12
Hi there,

got a small problem. Created a Form - the User selects a delivery No (L123456) and enters Data (SNR from our products).

It should not be possible to enter the same SNR within 2 delivery No. Thought of "testfield" but how to say the value you just entered compare with the values of the whole table and deny entrie if its already there??? (Can not use the key)

Cheers

Will

Comments

  • bbrownbbrown Member Posts: 3,268
    Use a second record variable to check for the value in the table
    There are no bugs - only undocumented features.
  • SV_WillSV_Will Member Posts: 12
    Hi bbrown,

    do you mean record variable for SNR or for my table. I tried


    Form - OnAfterGetCurrRecord()

    Seriennummer := SNRcheck;
    "Prod. Versand Line".TESTFIELD (Seriennummer,SNRcheck);

    Not working...
  • bbrownbbrown Member Posts: 3,268
    SV_Will wrote:
    Hi bbrown,

    do you mean record variable for SNR or for my table. I tried


    Form - OnAfterGetCurrRecord()

    Seriennummer := SNRcheck;
    "Prod. Versand Line".TESTFIELD (Seriennummer,SNRcheck);

    Not working...

    A record variable for the table. Isn't Seriennummer a field in that table?

    RecVar2.SETCURRENTKEY(a good key)
    RecVar2.SETRANGE(Seriennummer,SNRcheck);
    IF NOT RecVar.ISEMPTY THEN
    ERROR();
    There are no bugs - only undocumented features.
  • SV_WillSV_Will Member Posts: 12
    thanks so far, but still not working. I changed


    Seriennummer := SNRcheck;
    Versand2.SETRANGE(Seriennummer,SNRcheck);
    IF NOT Versand2.ISEMPTY THEN
    ERROR('Test');

    Versand2 is my second variable for the table. The table contains only one key so I dont need this line. The User inserts Seriennummer which is a field in my table. I created a form with a subform. The code is in the subform Trigger: Form - OnAfterGetCurrRecord()

    SNRcheck is just a global variable code 20 for the current data entry.

    ???
  • bbrownbbrown Member Posts: 3,268
    If Seriennummer is a field in the table and this is where the data is entered you do not need SNRcheck. The source for the textbox is Seriennummer.

    Versand2.SETRANGE(Seriennummer,Seriennummer);
    IF NOT Versand2.ISEMPTY THEN
    ERROR('Test');

    Call this from the OnValidate trigger of the Seriennummer field of the table.
    There are no bugs - only undocumented features.
  • SV_WillSV_Will Member Posts: 12
    Thanks a lot !!!!
Sign In or Register to comment.