First, thank you for the terrific program. It's working terrifically, however I'm stuck on one part... I'm attempting to write 3 tuples in a new row to the invisible table table1. I am emulating the subs that were in the Accounts program code that was included with the Basic4ppc software. Here is my file:
I get an Err1 "Entry Number must be unique." error on save, no matter what. Any ideas where I'm going wrong?
B4X:
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,"EntryNumber",1,True)
table1.AddCol(cString,"JudgeName",1)
table1.AddCol(cString,"Category",1)
table1.LoadCSV(dataFile,",",True,False)
table1.TableSort("EntryNumber ASC") 'Sets the Number (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
cmbJudgeName.SelectedIndex = table1.Cell("JudgeName",row)
cmbCategory.SelectedIndex = table1.Cell("Category",row)
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.Clear
cmbCategory.Clear
row = -1
End Sub
Sub btnRecord_Click
ErrorLabel (Err1)
changes = True
If Row = -1 Then
table1.AddRow(txtEntryNum.Text,cmbJudgeName.SelectedIndex,cmbCategory.SelectedIndex)
row = table1.RowCount - 1
ShowRow1
Else
table1.Cell("EntryNumber",row) = txtEntryNum.Text
table1.Cell("JudgeName",row) = cmbJudgeName.SelectedIndex
table1.Cell("Category",row) = cmbCategory.SelectedIndex
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
I get an Err1 "Entry Number must be unique." error on save, no matter what. Any ideas where I'm going wrong?