I swear I am sober…
I set up a little test to check something out and I am more at a loss now than before. Here’s what I did, the results and the code…
Xojo 2017 r 1.1
Max OS X 10.11.5 El Capitan on a MacBook Pro
Created a new window with a listbox, a textfield for RowCount, a textfield for RecordCount and a PushButton to add a new record.
There are no other Applications open and no other windows open.
When the window opens, everything is nominal, blank listbox, both textfields are zero
Click the button the first time and everything is still nominal, listbox has 1 row with the number 1 in it. Both textfields contain 1
Click the button a second time and things go South, the listbox is correct - 2 rows 1 & 2, the RecordCount textfield contains 2,
BUT THE ROWCOUNT TEXTFIELD CONTAINS 3
Click the button a third time and the RowCount textfield contains 6
A Fourth time and it contains 10!!!
The RowCount textfield always shows the sum of the numbers in the listbox rows.
All I am trying to get is the number of rows in the listbox…
The code in the Open event of the Window
[code]dim sSQL As String
dim iRows As Integer
dim iRecords As Integer
sSQL = “DROP TABLE IF EXISTS DBtest”
dbSQL.SQLExecute(sSQL)
sSQL = "CREATE TABLE DBtest( "
sSQL = sSQL + "pkRecID INTEGER PRIMARY KEY, "
sSQL = sSQL + “Comments TEXT)”
dbSQL.SQLExecute(sSQL)
if dbSQL.Error then MsgBox(dbSQL.ErrorMessage)
LoadListBox
iRows = Listbox1.ListCount
iRecords = rsRecords.RecordCount
RowCount.Text = str(Listbox1.ListCount)
RecordCount.Text = str(rsRecords.RecordCount)
Return[/code]
The code in the Action event of the pushbutton
[code]dim iRows As Integer
dim iRecords As Integer
dim NewRecord As new DatabaseRecord
NewRecord.Column(“Comments”) = “”
dbSQL.InsertRecord(“DBtest”, NewRecord)
if dbSQL.Error then MsgBox(dbSQL.ErrorMessage)
LoadListBox
iRows = Listbox1.ListCount
iRecords = rsRecords.RecordCount
RowCount.Text = str(Listbox1.ListCount)
RecordCount.Text = str(rsRecords.RecordCount)
Return
[/code]
The code in the LoadListBox method (the only method on the window)
[code]dim i As Integer
dim j As Integer
rsRecords = dbSQL.SQLSelect(“select * from DBtest”)
i = 0
j = rsRecords.RecordCount
rsRecords.MoveFirst
while not rsRecords.eof
ListBox1.addRow
ListBox1.cell( i, 0 ) = rsRecords.Field(“pkRecID”).StringValue
i = i + 1
rsRecords.MoveNext
Wend
[/code]
the only property is the rsRecords RecordSet (Private)
Can someone tell me what the blank is going on…