Yessica?
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 &
"'"
THIS STATEMENT makes a empty resultset
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 think maybe I have this error because calling the macro from a modified
state event of the combo box does not walk the resultSet of the form, but I
do not known how to obtain the customer_id except through this method.
Much appreciate a response.
regards,
Yessica