Return-Path: X-Original-To: apmail-openoffice-dev-archive@www.apache.org Delivered-To: apmail-openoffice-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 314E9D69B for ; Thu, 31 Jan 2013 07:34:50 +0000 (UTC) Received: (qmail 9337 invoked by uid 500); 31 Jan 2013 07:34:49 -0000 Delivered-To: apmail-openoffice-dev-archive@openoffice.apache.org Received: (qmail 9156 invoked by uid 500); 31 Jan 2013 07:34:49 -0000 Mailing-List: contact dev-help@openoffice.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openoffice.apache.org Delivered-To: mailing list dev@openoffice.apache.org Received: (qmail 9141 invoked by uid 99); 31 Jan 2013 07:34:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 31 Jan 2013 07:34:49 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of yessica.brinkmann@gmail.com designates 209.85.212.173 as permitted sender) Received: from [209.85.212.173] (HELO mail-wi0-f173.google.com) (209.85.212.173) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 31 Jan 2013 07:34:42 +0000 Received: by mail-wi0-f173.google.com with SMTP id hq4so112255wib.12 for ; Wed, 30 Jan 2013 23:34:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=l0/+an3ef3RxACm9fNCU1jzhCULRBwd4z/3EHVadYx8=; b=ATny5hlgrO+qP8tF2DEtUQgZSduHSAutFMZPUrM1mF/nZWGk4hwa1WJhmJ72qhneNi 07H8sWozK7PbYbQHPSpbdxzLJHJ7dZT+SnUga8xPn6QUvL8X9KZ/7pWP+xGO/L1OzJGP eme4KTTmK9iGSUD7yS7AfkKKOK/3CgcV+lT9mKo5nzdL0urYDRgiX1YxmmmPuE9zQ6V4 XomJkSMzI8WMiodIBAj+o3IhVqTpHNqKvSzz7+eP7v6s10YmPz9o5edbB9sz0QNd+Vvd sPhcHI0eWo3KbOp3clPXz3ysgjseVe6PYwzo5MGPEkZOcDUXY1xI+++6tKH+Moj2xI6C Ke0w== X-Received: by 10.194.21.70 with SMTP id t6mr13290995wje.42.1359617662286; Wed, 30 Jan 2013 23:34:22 -0800 (PST) MIME-Version: 1.0 Received: by 10.194.177.228 with HTTP; Wed, 30 Jan 2013 23:34:02 -0800 (PST) In-Reply-To: References: <510924FC.2050608@pitonyak.org> <5109A88D.3000400@pitonyak.org> <5109ED02.3080209@pitonyak.org> From: Yessica Brinkmann Date: Thu, 31 Jan 2013 04:34:02 -0300 Message-ID: Subject: Re: Error in macro. To: dev@openoffice.apache.org, andrew@pitonyak.org, sos@pmgroup.be Content-Type: multipart/alternative; boundary=047d7b5d3ef6ca7c6604d490a752 X-Virus-Checked: Checked by ClamAV on apache.org --047d7b5d3ef6ca7c6604d490a752 Content-Type: text/plain; charset=ISO-8859-1 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" 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 > 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 > >> >> 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 >>> >>> 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 >>>>> >>>>> 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 >>>>>> >>>>>> **> >>>>>> >>>>>> >>>>>> > >>>>>> Info: http://www.pitonyak.org/oo.php >>>>>> >>>>>> >>>>>> >>>>>> -- >>>> Andrew Pitonyak >>>> My Macro Document: http://www.pitonyak.org/****AndrewMacro.odt >>>> >>>> > >>>> Info: http://www.pitonyak.org/oo.php >>>> >>>> >>>> >> -- >> Andrew Pitonyak >> My Macro Document: http://www.pitonyak.org/**AndrewMacro.odt >> Info: http://www.pitonyak.org/oo.php >> >> > --047d7b5d3ef6ca7c6604d490a752--