openoffice-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fernand Vanrie <...@pmgroup.be>
Subject Re: Error in macro.
Date Thu, 31 Jan 2013 12:53:11 GMT
On 31/01/2013 13:33, Yessica Brinkmann wrote:
> Hello,
> Thank you very much for your answer. Sorry but I do not understand the
> truth indicated.
> What I want to do in my macro, as you can see in my first mail is an SQL
> UPDATE.
ok

you have a form, you fill this for with data comming from a "select" 
statement ,

the user change some data in the form

then you do a "update" using  THE (id) comming from the first "select" 
who is still available in the Resultset

for GETTING the id you do

  oRes.getstring(oRes.findcolumn("customer_id"))

for the changed data:

Total= oFrm.getByName("fmttotal").VALUE

> I can not find the client code for the name either, if that's what you
> suggest because this name is not necessarily unique, only the customer id
> is unique.
> regards,
> Yessica
>
> 2013/1/31 Fernand Vanrie <sos@pmgroup.be>
>
>> Yessica,
>>
>>   Hello,
>>> Yes, my controls now have the same name as the one I use to call the
>>> macro.
>>> Initially that was my mistake but I spent those mistakes. Now my problem
>>> is
>>> that I describe in my previous mail, on the subject of the combo box and
>>> customer_id and name.
>>> There is a key value associated with my combo box.
>>> On the Data tab of the Properties List, Contents List, I have the
>>> following
>>> SQL statement: SELECT "name", "customer_id" FROM "customer"
>>>
>> ok, your select end up in a Resultset in your code the object oRes
>>
>> your data are in oRes and you call a value like (supposed there is only 1
>> line in oRes)
>>   oRes.Next (line 1)
>>   oRes.getstring(oRes.**findcolumn("customer_id"))
>>
>>> My problem is that I do not know how to get the customer_id from the combo
>>> box in the macro to do the update in the customers table, since using the
>>> function getByName, I get the name of the client.
>>> Regards,
>>> Yessica
>>>
>>> 2013/1/31 Yessica Brinkmann <yessica.brinkmann@gmail.com>
>>>
>>>   Hello,
>>>> Thank you very much for your answer!
>>>> There is a key value associated with my combo box.
>>>> On the Data tab of the Properties List, Contents List, I have the
>>>> following SQL statement: SELECT "name", "customer_id" FROM "customer"
>>>> My problem is that I do not know how to get the customer_id from the
>>>> combo
>>>> box in the macro to do the update in the customers table, since using the
>>>> function getByName, I get the name of the client.
>>>> Regards,
>>>> Yessica
>>>>
>>>> 2013/1/31 Andrew Douglas Pitonyak <andrew@pitonyak.org>
>>>>
>>>>   Hopefully someone more in the know than I will answer, but, it is not
>>>>> clear to me that I have sufficient information to answer your question.
>>>>>
>>>>> I assume that your combo box is NOT multi-valued (don't even know if
>>>>> that
>>>>> is supported.... I have not looked at these in a very long time).
>>>>>
>>>>> is there something that ties your combo-box to some key value?
>>>>>
>>>>>
>>>>> On 01/30/2013 07:38 PM, Yessica Brinkmann wrote:
>>>>>
>>>>>   Hello,
>>>>>> Thank you very much for your answer! Now I understand what you're
>>>>>> saying.
>>>>>> I changed my macro, now looks like this:
>>>>>> Sub ActualizarSaldoVentas (Evento)
>>>>>> Dim oFrm As Object
>>>>>> Dim oCliente As Object
>>>>>> Dim oTotal As Object
>>>>>> Dim oCon As Object
>>>>>> Dim oStat As Object
>>>>>> Dim sSQL As String
>>>>>> Dim oRes As Object
>>>>>> Dim sCliente as String
>>>>>> 'Dim oIdPago As Object
>>>>>> oFrm=Evento.Source.Model.****Parent
>>>>>>
>>>>>> If oFrm.hasByName("id_cliente") Then
>>>>>>      oCliente=oFrm.getByName("id_****cliente")
>>>>>>
>>>>>> Else
>>>>>>      Print "Cannot find id_cliente"
>>>>>>      Exit Sub
>>>>>> End If
>>>>>> sCliente=oCliente.****getCurrentValue()
>>>>>> oTotal=oFrm.getByName("****fmttotal")
>>>>>>
>>>>>> Print sCliente
>>>>>> End Sub
>>>>>>
>>>>>> They were wrong names form controls.
>>>>>> The problem now is that when I write  Print sCliente, it prints the
>>>>>> name
>>>>>> of
>>>>>> the client (because it is a combo box) and not the id of the customer,
>>>>>> which is what I need to do my update. How I can do to get the client
>>>>>> id?
>>>>>> Can search by customer name obtained but this can be repeated, only
the
>>>>>> ID
>>>>>> is unique.
>>>>>> Much appreciate a response.
>>>>>> regards,
>>>>>> Yessica
>>>>>>
>>>>>> 2013/1/30 Andrew Douglas Pitonyak <andrew@pitonyak.org>
>>>>>>
>>>>>>    I think that AndrewBase.odt provides a routine that can find a
>>>>>> control
>>>>>>
>>>>>>> from its name.... It is not efficient, but it works.
>>>>>>>
>>>>>>> To get things by name, you must know where they live. You have
named
>>>>>>> forms
>>>>>>> and controls, so, I think that you can use the Forms navigator
(or
>>>>>>> something like that) to see the heirarchy.
>>>>>>>
>>>>>>>
>>>>>>> On 01/30/2013 10:24 AM, Yessica Brinkmann wrote:
>>>>>>>
>>>>>>>    Hello,
>>>>>>>
>>>>>>>> Thank you for the answers!
>>>>>>>> When I replaced the lines containing "getByName" for something
as
>>>>>>>> indicated
>>>>>>>> prints a message saying: "Can not find cod_cliente". I think
this is
>>>>>>>> because it is a field cod_cliente type drop-down list box
and i
>>>>>>>> should
>>>>>>>> get
>>>>>>>> the id of the customer through a cut chain or something,
but I really
>>>>>>>> do
>>>>>>>> not know how to do this in OO Basic. Can you help a little
with this
>>>>>>>> please? I clarify that my formal education rather relied
on the C and
>>>>>>>> Java.
>>>>>>>> regards,
>>>>>>>> Yessica
>>>>>>>>
>>>>>>>>
>>>>>>>> 2013/1/30 Andrew Douglas Pitonyak <andrew@pitonyak.org>
>>>>>>>>
>>>>>>>>     Which line gives the error?
>>>>>>>>
>>>>>>>>   If you change all lines containing "getByName" with something
like
>>>>>>>>> If oFrm.hasByName("cod_cliente") Then
>>>>>>>>>       oCliente=oFrm.getByName("cod_********cliente")
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Else
>>>>>>>>>       Print "Cannot find cod_cliente"
>>>>>>>>>       Exit Sub
>>>>>>>>> End If
>>>>>>>>>
>>>>>>>>> What happens?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On 01/30/2013 04:56 AM, Yessica Brinkmann wrote:
>>>>>>>>>
>>>>>>>>>     Hello,
>>>>>>>>>
>>>>>>>>>   I have a database of business management. I have a
customer table
>>>>>>>>>> that
>>>>>>>>>> has
>>>>>>>>>> a field saldo_actual.
>>>>>>>>>> On the other hand, I have a sales form, in which
I have a total
>>>>>>>>>> field,
>>>>>>>>>> and
>>>>>>>>>> a button Calculate Total.
>>>>>>>>>> I want to make a macro that when clicking on the
Calculate Total
>>>>>>>>>> button
>>>>>>>>>> to
>>>>>>>>>> add the total saldo_actual field.
>>>>>>>>>> I assigned the macro to the button event: Mouse button
released.
>>>>>>>>>> Then I
>>>>>>>>>> write my macro:
>>>>>>>>>> Sub ActualizarSaldoVentas (Evento)
>>>>>>>>>> Dim oFrm As Object
>>>>>>>>>> Dim oCliente As Object
>>>>>>>>>> Dim oTotal As Object
>>>>>>>>>> Dim oCon As Object
>>>>>>>>>> Dim oStat As Object
>>>>>>>>>> Dim sSQL As String
>>>>>>>>>> Dim oRes As Object
>>>>>>>>>> Dim sCliente as String
>>>>>>>>>> oFrm=Evento.Source.Model.********Parent
>>>>>>>>>> oCliente=oFrm.getByName("cod_********cliente")
>>>>>>>>>> sCliente=oCliente.********getCurrentValue()
>>>>>>>>>> oTotal=oFrm.getByName("total")
>>>>>>>>>> oCon=ThisDatabaseDocument.********CurrentController.******
>>>>>>>>>>
>>>>>>>>>> ActiveConnection
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> oStat=oCon.CreateStatement
>>>>>>>>>> sSQL="UPDATE cliente SET cliente.saldo_actual =
>>>>>>>>>> cliente.saldo_saldo_actual
>>>>>>>>>> + "& oTotal.getCurrentValue()& " WHERE id_cliente="
&
>>>>>>>>>> oCliente.getCurrentValue()
>>>>>>>>>> oRes=oStat.ExecuteQuery(sSQL)
>>>>>>>>>> End Sub
>>>>>>>>>> Clicking on the button Calculate total, I get the
following error:
>>>>>>>>>> BASIC runtime error. There was an exception.
>>>>>>>>>> Type: com.sun.star.container.********NoSuchElementException
>>>>>>>>>> Message:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> I would appreciate very much a help please.
>>>>>>>>>> regards,
>>>>>>>>>> Yessica
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>     --
>>>>>>>>>>
>>>>>>>>>>   Andrew Pitonyak
>>>>>>>>> My Macro Document: http://www.pitonyak.org/********AndrewMacro.odt<http://www.pitonyak.org/******AndrewMacro.odt>
>>>>>>>>> <http://www.**pitonyak.org/****AndrewMacro.**odt<http://www.pitonyak.org/****AndrewMacro.odt>
>>>>>>>>> <http://www.**pitonyak.org/****AndrewMacro.odt<http://pitonyak.org/**AndrewMacro.odt>
>>>>>>>>> <http://www.**pitonyak.org/**AndrewMacro.odt<http://www.pitonyak.org/**AndrewMacro.odt>
>>>>>>>>> **>
>>>>>>>>> **>
>>>>>>>>> <http://www.**pitonyak.org/****AndrewMacro.odt<http://pitonyak.org/**AndrewMacro.odt>
>>>>>>>>> <http://**pitonyak.org/AndrewMacro.odt<http://pitonyak.org/AndrewMacro.odt>
>>>>>>>>> <http://www.**pitonyak.org/**AndrewMacro.odt<http://pitonyak.org/AndrewMacro.odt>
>>>>>>>>> <http://www.**pitonyak.org/AndrewMacro.odt<http://www.pitonyak.org/AndrewMacro.odt>
>>>>>>>>> Info:  http://www.pitonyak.org/oo.php
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>    --
>>>>>>>>>
>>>>>>>> Andrew Pitonyak
>>>>>>> My Macro Document: http://www.pitonyak.org/******AndrewMacro.odt<http://www.pitonyak.org/****AndrewMacro.odt>
>>>>>>> <http://www.**pitonyak.org/**AndrewMacro.odt<http://www.pitonyak.org/**AndrewMacro.odt>
>>>>>>> **>
>>>>>>> <http://www.**pitonyak.org/**AndrewMacro.odt<http://pitonyak.org/AndrewMacro.odt>
>>>>>>> <http://www.**pitonyak.org/AndrewMacro.odt<http://www.pitonyak.org/AndrewMacro.odt>
>>>>>>> Info:  http://www.pitonyak.org/oo.php
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>   --
>>>>> Andrew Pitonyak
>>>>> My Macro Document: http://www.pitonyak.org/****AndrewMacro.odt<http://www.pitonyak.org/**AndrewMacro.odt>
>>>>> <http://www.**pitonyak.org/AndrewMacro.odt<http://www.pitonyak.org/AndrewMacro.odt>
>>>>> Info:  http://www.pitonyak.org/oo.php
>>>>>
>>>>>
>>>>>


Mime
View raw message