Hello, I would ask please if anyone can answer this question because I really need to implement this functionality. regards, Yessica
2013/2/6 Yessica Brinkmann <yessica.brinkm...@gmail.com> > Hello, > I have a macro in a form called Sales Payments. > What the macro should do is this: when you select a customer from a > combo box, take the current balance of the customer (which is in the > the Customer table, saldo_actual field) and put it into a form field > Payments Sales called balance. I associated my macro to the > modificated state event of the combo box. > The problem is that when you select a customer from the combo box, I > get the following error: > Runtime Error Basic. > There was an exception. > Type: com.sun.star.sdbc.SQLException. > Message: The cursor points before the first row or after the last. > My macro is: > Sub ActualizarSaldoCliente(Evento) > Dim oCon As Object > Dim oStat As Object > Dim oSaldo As Object > Dim sSQL As String > Dim oCliente As Object > Dim sCliente as String > Dim oRes As Object > Dim oFrm As Object > oFrm=Evento.Source.Model.Parent > If oFrm.hasByName("cod_cliente") Then > oCliente=oFrm.getByName("cod_cliente") > Else > Print "Cannot find cod_cliente" > Exit Sub > End If > rs=oFrm.createResultSet() > sCliente=rs.getString(rs.findColumn("id_cliente")) > > > > sSQL = "SELECT saldo_actual FROM cliente WHERE id_cliente='" & > sCliente & "'" > > > oCon = ThisDatabaseDocument.CurrentController.ActiveConnection > oStat = oCon.CreateStatement > oRes = oStat.ExecuteQuery(sSQL) > > If oRes.next Then > > oSaldo.BoundField.Value = oRes.getDouble(1) > Else > oSaldo.BoundField.Value=0 > End If > > End Sub > > The error occurs on the line: > sCliente=rs.getString(rs.findColumn("id_cliente")) > I understand that the ResultSet is empty, but I do not understand why > it is empty. > > Much appreciate a response. > regards, > Yessica >