Home > Language Reference > Classes > Database

CategoryName Property

Set or return a category name.

Syntax

Public Property Get CategoryName(ByVal iIndex As Integer) As String
Public Property Let CategoryName(ByVal iIndex As Integer, ByRef sName As String)

ParameterDescription
iIndexCategory index.
sNameCategory name.

Remarks

This property creates, sets or returns the name of a category. The range of valid values of iIndex is 0 to 15. The maximum size of sName is 15 characters. If sName is greater than 15 characters, it is truncated.

In the following example, a database is created and two categories are added using the CategoryName method. Then a few records are added, and each time a category is assigned to them. A Popup control allows the user to filter the records using the CategorySelect method:

Private Sub  Form_Load()
Dim  i As Integer
  'Open / Create the recordset
  rs.OpenTable hbModeCreateAlways +hbModeReadWrite

  'Add two category
  rs.CategoryName(1)="Odd"
  rs.CategoryName(2)="Even"
  
  'Add one record : 1 is Odd so its Category is index 1 (Odd)
  rs.AddNew
  rs.Data=1
  rs.Category=1
  rs.Update
  'Add one record : 2 is Even so its Category is index 2 (Even) 
  rs.AddNew
  rs.Data=2
  rs.Category=2
  rs.Update
  'Add one record : 3 is Odd so its Category is index 1 (Odd)
  rs.AddNew
  rs.Data=3
  rs.Category=1
  rs.Update
  'Add one record : 4 is Even so its Category is index 2 (Even) 
  rs.AddNew
  rs.Data=4
  rs.Category=2
  rs.Update

  iCat=0
  Popup1.Text="Click me!"
  FillList
End Sub

Private Sub FillList()
  List1.Redraw=False
  List1.Clear
  if iCat>0 then  'Category 0 mean All
    rs.OpenRecordset "Category=" & iCat,hbModeOpenExisting+hbModeReadWrite
  else            'Query for iCat Category index
    rs.OpenTable hbModeOpenExisting+hbModeReadWrite
  end if
  'Fill the list
  if not rs.BOF and not rs.EOF Then
    rs.MoveFirst
    While not rs.EOF
      List1.AddItem rs.Data
      rs.MoveNext
    Wend
  End if  
  List1.Redraw=true
End Sub

Private Sub Popup1_Click()
  'call the system Category popup list
  iCat=Popup1.CategorySelect(rs,iCat,0,true,true)
  FillList
End Sub

System requirements

SystemMinimal versionRemarks
Palm OSPalm OS 3.0N/A