Load data from SQL server to unbound DBGrid
Posted on 1998-05-05
I have a form for invoice change. The user need to input an invoice no. first, after pressing [Enter] key, the details of the invoice would be shown on an unbound dbgrid. I found that after loading 1 row data, a run-time error "Invalid row number" occured.
The following is my codings.
iRow = 0
SelectLoanItem = "SELECT ItemNo,Description,Serial FROM vwLoanDetailsForIIP "
SelectLoanItem = SelectLoanItem & "WHERE LoanNo = " & CInt(TxtLoanNo)
Set Myrecordset = MyDatabase.OpenRecordset(SelectLoanItem)
Do Until Myrecordset.EOF
DBGridLoanItem.Row = iRow
DBGridLoanItem.Columns(0) = Myrecordset!itemno
DBGridLoanItem.Columns(1) = Myrecordset!Description
DBGridLoanItem.Columns(2) = Myrecordset!Serial
iRow = iRow + 1