Sub Globals
'Declare the global variables here.
row = 0 'record ID
dataFile = "BikeShow.csv"
changes = False 'Used for the 'save changes before exit' question
End Sub
Sub App_Start
frmStart.Show
'ErrorLabel (Err)
'Adds the table columns
table1.AddCol(cString,"EntryNum",1,True)
table1.AddCol(cString,"JudgeName",1)
table1.AddCol(cString,"Category",1)
table1.LoadCSV(dataFile,",",True,False)
table1.TableSort("EntryNum ASC") 'Sets the EntrynNum (entry number) column as the sort field
ShowRow1
Return
Err:
Msgbox("Error Loading Data File.","",cMsgboxOK,cMsgboxHand)
End Sub
Sub ShowRow1 'Shows first page rows from table if they exist
If row<table1.RowCount AND row > -1 Then
cmbJudgeName.SelectedIndex = table1.Cell("JudgeName",row)
cmbCategory.SelectedIndex = table1.Cell("Category",row)
End If
End Sub
Sub mnuSave_Click
changes = False
table1.SaveCSV(dataFile,",",True) 'Saves the data as a CSV File.
End Sub
Sub mnuAdd_Click
txtEntryNum.Text = ""
cmbJudgeName.SelectedIndex = -1
cmbCategory.SelectedIndex = -1
row = -1
End Sub
Sub btnRecord_Click
changes = True
If row<table1.RowCount AND row > -1 Then
'''-------------> add more code to prevent duplicate enteries here
'''-----------------------------------------------------------------------------
table1.Cell("EntryNum",row) = txtEntryNum.Text
table1.Cell("JudgeName",row) = cmbJudgeName.SelectedIndex
table1.Cell("Category",row) = cmbCategory.SelectedIndex
Else
' add new row
row = -1
End If
If Row = -1 Then
table1.AddRow(txtEntryNum.Text,cmbJudgeName.SelectedIndex,cmbCategory.SelectedIndex)
row = table1.RowCount - 1
ShowRow1
Else
End If
Return
Err1:
Msgbox("Entry Number must be unique.","",cMsgboxOK,cMsgboxHand)
End Sub
Sub Form1_Close
If changes = True Then
i = Msgbox("Do you want to save changes?","",cMsgboxYesNoCancel,cMsgboxQuestion)
If i = cYes Then
mnuSave_Click
Else If i = cCancel Then
frmStart.CancelClose
End If
End If
End Sub