Method
Retrieves the number of a specified field that is identified by
name.
Category
Fields
Syntax
Function FieldNo(ByVal hTable As Long, ByVal FieldName As String)
As Long
hTable
The handle to the table.
FieldName
The name of the field whose number is to be retrieved.
Example
'Case "FieldInfo"
'Lists the information about the fields in the customer-table
tmpLong = CF1.NextField(hTable, 0)
Do While tmpLong <> 0
tmpBool = False
tmpStr = Str$(CF1.FieldLen(hTable, tmpLong)) & ", "
tmpVar = CF1.FieldName(hTable, tmpLong)
If VarType(tmpVar) = vbString Then
tmpStr = tmpStr & tmpVar & ", "
tmpVar2 = CF1.FieldNo(hTable, tmpVar)
If VarType(tmpVar2) = vbLong Then
tmpStr = tmpStr & tmpVar2 & ", "
tmpVar2 = CF1.FieldType(hTable, tmpLong)
If VarType(tmpVar2) = vbInteger Then
tmpStr = tmpStr & tmpVar2 & ", "
tmpVar2 = CF1.FieldSize(hTable, tmpLong)
If VarType(tmpVar2) = vbInteger Then
tmpStr = tmpStr & tmpVar2 & ", "
tmpVar2 = CF1.FieldClass(hTable, tmpLong)
If VarType(tmpVar2) = vbInteger Then
tmpStr = tmpStr & tmpVar2 & ", "
tmpVar2 = CF1.FieldOptionStr(hTable, tmpLong)
If VarType(tmpVar2) = vbString Then
tmpStr = tmpStr & tmpVar2
tmpLong = CF1.NextField(hTable, tmpLong)
tmpBool = True
End If
End If
End If
End If
End If
End If
If Not (tmpBool) Then
Exit Do
End If
Loop
If tmpBool Then
tmpStr = "Fieldinfo from the last field: " & tmpStr
logWr tmpStr
Else
logWr "Error in a return value"
End If
CF1.CloseTable hTable
Comments
FieldNo returns the field number of FieldName.
Each field is uniquely identified by both a number and a name. Two fields in the same table cannot have the same number or name - this is checked when fields are created in C/SIDE.
Fields are normally accessed by number because the random access used for numbers is faster than the sequential scan used for names. Therefore, only call FieldNo to look up the number of a field if your system does not support field numbers, and there is no alternative.
If FieldName does not exist, 0 is returned.
See also FieldNoArray.