openoffice-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Regina Henschel <rb.hensc...@t-online.de>
Subject Re: Problem with combobox associated macro
Date Thu, 07 Feb 2013 20:27:08 GMT
Hi Yessica,

Yessica Brinkmann schrieb:
> Thank you very much for your answer. Yes, I understand this. What I do not
> understand is why the ResultSet is empty. I used the same sentences as in
> my previous macro (ActualizarSaldoVentas), and the ResultSet that macro was
> not empty. You could help me a little more with this please?
> regards,
> Yessica

I'm not familiar with the combination of Base and Basic, but here are 
two general tips which might help you to find the error:
1. Always use the statement
Option Explicit
as very first line in your module. It forces you to always declare the 
variables. And that is necessary, because the automatic type assignment 
might not work as you expect.
2. Set breakpoints and use the watch window to see, what the actual 
value of a variable really is and whether it has the expected type.

Do you already know "Using Macros With OOo Base By Andrew Pitonyak" or 
the follow-up http://www.pitonyak.org/database/AndrewBase.odt ?

Kind regards
Regina


>
> 2013/2/6 Fernand Vanrie <sos@pmgroup.be>
>
>> 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
>>>
>>>
>>
>


Mime
View raw message