I have a problem that I cannot resolve. Below are to SELECT*FROM codes using the same database and the SAME Table. The upper code will show a list in the list box while the lower code will have a While not rs.eof problem.
I have spent days trying to find the error but to me the codes are the same. Does anyone know why one block of code will work while another will not? Programmers on the forum were kind enough to help me before so if someone would point out my mistake I’d appreciate it.
I’ve been looking for a work-around for this code but haven’t found any in the tutorials.
Thank you in advance for giving my problem your consideration. I believe this will be my last inquiry.
Jim Backus
THIS CODE WILL SHOW RECORDS AND DOES NOT HAVE A WHILE NOT RS.EOF ERROR
Dim sql as String
Dim SearchExpense as String
Dim rs as recordSet
SearchExpense = txtSearchExpense.text
sql =“SELECT * FROM Purchases WHERE ExpenseType = '” + SearchExpense + “'”
rs = App.SLivingDB.SQLSelect(sql)
PopulateSearchListBox SearchLB, rs
rs.close
THIS CODE HAS A WHILE NOT RS.EOF ERROR
Dim sql as String
Dim SearchMonth as String
Dim rs as recordSet
SearchMonth = txtSearchMonth.text
sql = "SELECT * FROM Purchases WHERE Month = "’ + SearchMonth + “'”
rs = App.SLivingDB.SQLSelect(sql)
PopulateSearchListBox SearchLB, rs
rs.close
BOTH ABOVE CODES USE THE SAME POPULATE code below
// Set the headings for the searchLB list box
SearchLB.HasHeading = True
SearchLB.Heading(0) = “ID”
SearchLB.Heading(1) = “Expense”
SearchLB.Heading(2) = “Payment”
SearchLB.Heading(3) = “Company”
SearchLB.Heading(4) = “Amount”
SearchLB.Heading(5) = “Note”
SearchLB.Heading(6) = “Month”
SearchLB.Heading(7) = “Year”
Dim I as integer
// Clear the listbox
lb.deleteAllRows
// Loop unitl reach end of recordSet
While not rs.eof
lb.addRow""
For i = 1 to rs.fieldCount
lb.cell(lb.lastIndex, i - 1 ) = rs.idxField(i).stringValue
Next
rs.moveNext
Wend
5 posts - 5 participants