Page 1 of 1

Check if text in field already existsalready exists

Posted: Mon Mar 06, 2023 8:33 pm
by CAsba
Hi,
I've made a function that makes a code from the initials of a customer name. The code is put into a field called 'newcode' and is later used as the index of the customer line in a database. How can it be scripted to check if the code made already exists, and if it does, to suffix this latest instance of it incrementally (by 1) to distinguish it from one or more previous similar codes? I've tried using the 'exists' and 'there is ' functions without success or any idea of the syntax for this context.

Re: Check if text in field already existsalready exists

Posted: Mon Mar 06, 2023 11:06 pm
by dunbarx
CAsba.

Is there only a single field where all these new codes are stored? If so, just (pseudo):

Code: Select all

if yourNewCode is not in fld "newCode" then loadNewCode
There are other, similar variants, such as. (pseudo):

Code: Select all

if yourNewCode is not among the words in fld "newCode" then loadNewCode
Craig

Re: Check if text in field already existsalready exists

Posted: Mon Mar 06, 2023 11:09 pm
by dunbarx
Rereading, in order to help you with the second part of your question, how to modify a new code where a copy already exists, tell me how the codes are entered into the field. One per line, for example?

In this way we can construct the currently non-existent handler "loadnewCode" so that it does the work in either situation.

Craig

Re: Check if text in field already existsalready exists

Posted: Wed Mar 08, 2023 11:59 am
by CAsba
Hi Craig,
I wonder, is it possible to check if the text in field newcode is already being used in a datagrid, relating to another customer with the same initials on which the customer code is based . (The text in field newcode will be entered into the datagrid, but cannot be the same as another datagrid entry.)

Re: Check if text in field already existsalready exists

Posted: Wed Mar 08, 2023 12:46 pm
by CAsba
Hi again, Craig,
Ignore my last, I got it working via a field as you suggested.