4D v14.3Find in field |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v14.3
Find in field
|
Find in field ( targetField ; value ) -> Function result | ||||||||
Parameter | Type | Description | ||||||
targetField | Field |
![]() |
Field on which to execute the search | |||||
value | Field, Variable |
![]() |
Value to search | |||||
![]() |
Value found | |||||||
Function result | Longint |
![]() |
Number of the record found or -1 if no record was found | |||||
The Find in field command returns the number of the first record whose targetField field is equal to value.
If no records are found, Find in field returns -1.
After calling this command, value contains the value found. This feature allows you to execute searches using the wildcard character (“@”) on Alpha fields and then retrieve the value found.
This command doesn’t modify the current selection or the current record.
It is fast and particularly useful to avoid creating double entries during data entry.
Historical note: In earlier versions of 4D, the Find in field command was named Find index key and only worked with indexed fields. Beginning with 4D v11 SQL, this limitation was removed and the command was renamed.
In an audio CD database, during data entry let’s assume that you want to verify the singer’s name to see if it already exists in the database. Because homonyms can exist, you don’t want the [Singer]Name field to be unique. Therefore, in the input form, you can write the following code in the [Singer]Name field’s object method:
If(Form event=On Data Change)
$RecNum:=Find in field([Singer]Name;[Singer]Name)
If($RecNum #-1) ` If this name has already been entered
CONFIRM("A singer with the same already exists. Do you want to see the record?";"Yes";"No")
If(OK=1)
GOTO RECORD([Singer];$RecNum)
End if
End if
End if
Product: 4D
Theme: Queries
Number:
653
Modified: 4D v11 SQL
Trouver clef index
4D Language Reference ( 4D v12.4)
4D Language Reference ( 4D v11 SQL Release 6)
4D Language Reference ( 4D v14 R3)
4D Language Reference ( 4D v14 R2)
4D Language Reference ( 4D v13.5)
4D Language Reference ( 4D v14.3)
4D Language Reference ( 4D v14 R4)