VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Indexer"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit
'Klasa Indexer
'Pozwala tworzyć nowe tabele
'Dodawać do nich kolumny
'I tworzyć indeksy
Dim tb As TableDef
Private db As Database
'--------
Public Sub makeTable(datab, nm As String)
  Set db = datab
  Set tb = db.CreateTableDef(nm)
End Sub
'--------
Public Sub openTable(datab As Database, nm As String)
  Set db = datab
  Set tb = db.TableDefs(nm)
End Sub
'--------
Public Sub addTable()
  db.TableDefs.Append tb
End Sub
'--------
Public Sub createKey(nm As String)
  Dim key As Field
  Set key = tb.CreateField(nm, dbLong)
  key.Attributes = dbAutoIncrField
  tb.Fields.Append key
End Sub
'--------
Public Sub createText(nm$, length As Integer)
  Dim tx As Field
  Set tx = tb.CreateField(nm$, dbText)
  tx.Size = length
  tx.AllowZeroLength = True
  tx.DefaultValue = ""
  tb.Fields.Append tx
End Sub
'--------
Public Sub createDateField(nm As String)
  Dim dt As Field
  Set dt = tb.CreateField(nm$, dbDate)
  tb.Fields.Append dt
End Sub
'--------
Public Sub createCurrency(nm As String)
  Dim c As Field
  Set c = tb.CreateField(nm$, dbCurrency)
  tb.Fields.Append c
End Sub
'--------
Public Sub makeIndex(nm$, primary As Boolean)
  Dim pindex As Index, pf As Field
  Set pindex = tb.CreateIndex(nm)
  If primary Then
    pindex.primary = True
    pindex.Unique = True
  Else
    pindex.primary = False
    pindex.Unique = False
  End If
  Set pf = pindex.CreateField(nm)
  pindex.Fields.Append pf
  tb.Indexes.Append pindex
End Sub
'--------
Public Sub createLong(nm As String)
  Dim dt As Field
  Set dt = tb.CreateField(nm$, dbLong)
  dt.DefaultValue = 0
  tb.Fields.Append dt
End Sub
'--------
Public Sub createInteger(nm As String)
  Dim dt As Field
  Set dt = tb.CreateField(nm$, dbInteger)
  dt.DefaultValue = 0
  tb.Fields.Append dt
End Sub
'--------
Public Sub createSingle(nm As String)
  Dim dt As Field
  On Local Error Resume Next
  Set dt = tb.CreateField(nm$, dbSingle)
  dt.DefaultValue = 0
  tb.Fields.Append dt
End Sub
'--------
Public Sub createBoolean(nm As String)
  Dim dt As Field
  Set dt = tb.CreateField(nm$, dbBoolean)
  tb.Fields.Append dt
End Sub
'--------
Public Sub createBooleanTrue(nm As String)
  Dim dt As Field
  Set dt = tb.CreateField(nm$, dbBoolean)
  dt.DefaultValue = "-1"
  tb.Fields.Append dt
End Sub

