' Similar to ExecuteSpinner (see DBUtils).
' Returns (and sets into the spinner tag) a map which has:
' key = DescriptionFieldName - the field shown in the spinner
' value = IDFieldName - the ID (int) which should be the Primary Key.
Sub ExecuteSpinnerMap(SQL As SQL, _
spn As Spinner, _
Clear As Boolean, _
tbl As String, _
IDFieldName As String, _
DescriptionFieldName As String, _
CaseSensitive As Boolean, _
OrderBy As Boolean) As Map
Dim SQLString As String
SQLString = "SELECT " & IDFieldName & "," & DescriptionFieldName & " FROM " & tbl
If OrderBy = True Then
If CaseSensitive = True Then
SQLString = SQLString & " ORDER BY UPPER(" & DescriptionFieldName & ")"
Else
SQLString = SQLString & " ORDER BY " & DescriptionFieldName
End If
End If
If Clear = True Then
spn.Clear
End If
Dim Table As List
Dim mapDescrID As Map : mapDescrID.Initialize
Table = ExecuteMemoryTable(SQL, SQLString, Null, 0)
If Table.IsInitialized Then
Dim Cols() As String
For i = 0 To Table.Size - 1
Cols = Table.Get(i)
spn.Add(Cols(1))
mapDescrID.Put(Cols(1), Cols(0))
Next
spn.Tag = mapDescrID
End If
Return mapDescrID
End Sub