// code in the method executed on Window Open event to populate the ListBox
dim i As Integer
dim sRecID As String
dim iRecID As Integer
dim sFirstName As String
dim sLastName As String
dim sName As String
dim sLodge As String
dim sErrMsg As String
sSQL = "SELECT * FROM Masons"
rsRecall = dbSQL.SQLSelect(sSQL)
if dbSQL.Error then
MsgBox(dbSQL.ErrorMessage)
sErrMsg = "DATABASE ERROR - " + dbSQL.ErrorMessage
UpdateLog("wMasons.PopulateListBox", sErrMsg)
quit
Return
end if
rsRecall.MoveFirst
iCurrentRecord = rsRecall.Field( "pkRecID" ).IntegerValue
lbMasons.deleteAllRows
i = 0
while not rsRecall.eof
iRecID = rsRecall.Field( "pkRecID" ).IntegerValue
sFirstName = rsRecall.Field( "GoesByName" ).StringValue
sLastName = rsRecall.Field( "LastName" ).StringValue
sName = sLastName + ", " + sFirstName
sLodge = rsRecall.Field( "fkHomeLodge" ).StringValue
lbMasons.addRow "1"
lbMasons.cell( i, 0 ) = str(iRecID)
lbMasons.cell( i, 1 ) = sName
lbMasons.cell( i, 2 ) = sLodge
i = i + 1
rsRecall.MoveNext
wend
//Code in the DoubleClick Event of the ListBox
//Have also used the same code in the MouseDown event
dim iRow As Integer
dim sMasonID As String
dim sName As String
iRow = Me.RowFromXY(System.MouseX - Me.Left - Self.Left, System.MouseY - Me.Top - Self.Top)
sMasonID = lbMasons.cell( iRow, 0 )
sName = lbMasons.cell( iRow, 1 )
tfMasonIDTest.Text = sMasonID
tfMasonNameTest.Text = sName
tfRowTest.Text = str(iRow)
//GoToRecord(sMasonID)
//TabPanel1.Value = 0
//PopulateDataEntryFields
return
I have a problem I can not get my head around. I have a very simple listbox with 3 columns. The table it is being loaded from has a total of 16 records.
The top code block above is executed on window open to populate the listbox from the records in the table - appears to work properly.
The lower code block is executed in the doubleclick event of the listbox.
The desired result of a double click is to go to the corresponding record which was clicked on, populate the TextFields on the main panel and then to move from the panel with the listbox to the main panel with the editing fields.
The 3 lines commented out are the desired end result of a double click. The 3 lines above them populate textfields on the same panel with the listbox just to test and look at what is happening.
BUT… When I double click a row, the resulting data indicates I clicked on row + 1 and further the selected record is then 1 past that. In other words, I click on the top row (row 0), the iRow shows 1, but the selected record is the 3rd row.
Even stranger, when I put a debug mark and watch the execution in the debugger. then iRow ALWAYS results in 0, regardless of which row is clicked.
No matter which row I click on, the record 2 rows down is selected. I even created a new list box from scratch but on the same panel and used the same method to populate it. It does the same thing.
On the main panel of the tabcontrol (with the detailed data entry fields) I have navigation buttons that go to first, next, previous, and last records. This works fine.
Is there a possibility that the table is corrupted? Should I create a new table and then copy the data to the new table?
Someone PLEASE explain what’s going on.
thanks,
Bill