Re: Error in macro.

2013-02-03 Thread Fernand Vanrie

Op 02/02/2013 11:20, Yessica Brinkmann schreef:

Hello,
Yes, I write: SELECT cliente.saldo_actual FROM cliente WHERE id_cliente=0
and it works. It say: Command executed successfully.
The column name is saldo_actual , so I wrote in my last version of the
macro, which is in my previous mail.

If its run in a query, than it must also in the macro ?
TRYE to run a other macro with only the statement with the id and the 
value hardcoded

Regards,
Yessica

2013/2/2 Fernand Vanrie s...@pmgroup.be


Op 02/02/2013 07:04, Yessica Brinkmann schreef:

  Hello,

I wanted to ask if I can please help with this issue. Is that really need
to implement this functionality for my database. The macro has no errors
but UPDATE is not performed in the customer table. I do not know if you
owe
the event in which I am putting my macro, event currently in the Mouse
button released Calculate Total button. Same should work if saldo_actual
field for a record is empty it?


do the sql statement works when run from elsewhere (make a query to test)


I also see that all new users first make an introduction, I'm doing my
thesis on  Computer Engineering and I am working Independent, as do
systems. I have more experience working on Java and XML, but I think this
is a nice opportunity to learn Visual Basic.
My macro is now as follows:
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 rs As Object
Dim sCliente as String
Dim ColIndex as Integer
'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
 rs=oFrm.createResultSet()
 sCliente=rs.getString(rs.**findColumn(cod_cliente))
 oTotal=oFrm.getByName(**fmttotal)
 Print sCliente
 Print oTotal.getCurrentValue()
 oCon=ThisDatabaseDocument.**CurrentController.**ActiveConnection
 oStat=oCon.CreateStatement
 sSQL = UPDATE cliente   SET cliente.saldo_actual = 

cliente.saldo_actual +   oTotal.getCurrentValue()   WHERE
cliente.id_cliente=  CInt(sCliente)
 oRes=oStat.ExecuteQuery(sSQL)
End Sub
Regards,
Yessica
2013/2/1 Yessica Brinkmann yessica.brinkm...@gmail.com

  Hello,

I think maybe I should assign my macro to another event, perhaps one
associated with the form to work, I do not know, my idea is just. Tempted
now assigned to mouse button released event of a button called Calculate
Total.
regards,
Yessica

2013/2/1 Yessica Brinkmann yessica.brinkm...@gmail.com

  Hello,

Thank you very much for the reply. Sorry, did not know that I should not
put attachments. Now I have no errors in the macro, and I used the SQL
UPDATE indicated. Just do not know why but UPDATE fails. So, when I
check
the table, I do not see the value of the changed field. I refreshed the
table also but nothing. I printed the total value also to see if I was
right and good. I do not know what is going wrong.
Regards,
Yessica

2013/2/1 Fernand Vanrie s...@pmgroup.be

  Ariel, Yessica,

with OObase database, table and field names are case sensitive, their
is
no need to quote if:  tables are lowercase and fieldnames uppercase.

if quotes are used, then leave the dots out of the quotes
   sSQL= SELECT mybase.cliente.saldo_saldo_actual

WHERE works

greetz

Fernand

   On Thu, Jan 31, 2013 at 08:01:22PM -0300, Yessica Brinkmann wrote:


Hi, thanks for your answer.

Now I advanced.
I print the value of the client code correctly.
Only now I have another error, tells me that the Customer table does
not
exist or something like this:
Basic runtime error. There was an exception. Type:
com.sun.star.sdbc.SQLException. Message: Table not found in
statement

  This may need to quote table and fields names:

   sSQL=UPDATE cliente SET cliente.saldo_actual =


cliente.saldo_saldo_actual +  oTotal.getCurrentValue()  WHERE
cliente.id_cliente=  CInt(sCliente)

  What is the name of the table? CLIENTES or clientes?


Regards






Re: Error in macro.

2013-02-03 Thread Yessica Brinkmann
Hello, thank you very much for your answers. I created a macro as you show
me, and it works:
Sub modificacion
oCon=ThisDatabaseDocument.CurrentController.ActiveConnection
oStat=oCon.CreateStatement
sSQL = UPDATE cliente  SET cliente.saldo_actual =  
cliente.saldo_actual +   1000   WHERE
 cliente.id_cliente =  1
oRes=oStat.ExecuteQuery(sSQL)
End Sub
Also my original macro works, but the problem is it only works if manually
SETTING saldo_actual field to 0 previously. That is my macro works, now my
problem is that I can not put defaults to 0 to saldo_actual field. As I had
said in my previous mail, I put in value If required, I deleted all records
from the cliente table and have even removed all relationships with other
tables, just do not let me, I can not just save the changes made and the
cursor is just saldo_actual field.
Regards,
Yessica
2013/2/3 Fernand Vanrie s...@pmgroup.be

 i opened your base document , opened to edit your cliente table, close and
 run your macro
 now your macro works :-)


 Op 03/02/2013 13:38, Fernand Vanrie schreef:

  Op 02/02/2013 11:20, Yessica Brinkmann schreef:

 Hello,
 Yes, I write: SELECT cliente.saldo_actual FROM cliente WHERE id_cliente=0
 and it works. It say: Command executed successfully.
 The column name is saldo_actual , so I wrote in my last version of the
 macro, which is in my previous mail.

 If its run in a query, than it must also in the macro ?
 TRYE to run a other macro with only the statement with the id and the
 value hardcoded

 Regards,
 Yessica

 2013/2/2 Fernand Vanrie s...@pmgroup.be

  Op 02/02/2013 07:04, Yessica Brinkmann schreef:

   Hello,

 I wanted to ask if I can please help with this issue. Is that really
 need
 to implement this functionality for my database. The macro has no
 errors
 but UPDATE is not performed in the customer table. I do not know if you
 owe
 the event in which I am putting my macro, event currently in the Mouse
 button released Calculate Total button. Same should work if
 saldo_actual
 field for a record is empty it?

  do the sql statement works when run from elsewhere (make a query to
 test)

  I also see that all new users first make an introduction, I'm doing my
 thesis on  Computer Engineering and I am working Independent, as do
 systems. I have more experience working on Java and XML, but I think
 this
 is a nice opportunity to learn Visual Basic.
 My macro is now as follows:
 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 rs As Object
 Dim sCliente as String
 Dim ColIndex as Integer
 '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
  rs=oFrm.createResultSet()
 sCliente=rs.getString(rs.findColumn(cod_cliente))
  oTotal=oFrm.getByName(fmttotal)
  Print sCliente
  Print oTotal.getCurrentValue()
 oCon=ThisDatabaseDocument.CurrentController.ActiveConnection
  oStat=oCon.CreateStatement
  sSQL = UPDATE cliente   SET cliente.saldo_actual
 = 
 
 cliente.saldo_actual +   oTotal.getCurrentValue()   WHERE
 cliente.id_cliente=  CInt(sCliente)
  oRes=oStat.ExecuteQuery(sSQL)
 End Sub
 Regards,
 Yessica
 2013/2/1 Yessica Brinkmann yessica.brinkm...@gmail.com

   Hello,

 I think maybe I should assign my macro to another event, perhaps one
 associated with the form to work, I do not know, my idea is just.
 Tempted
 now assigned to mouse button released event of a button called
 Calculate
 Total.
 regards,
 Yessica

 2013/2/1 Yessica Brinkmann yessica.brinkm...@gmail.com

   Hello,

 Thank you very much for the reply. Sorry, did not know that I should
 not
 put attachments. Now I have no errors in the macro, and I used the
 SQL
 UPDATE indicated. Just do not know why but UPDATE fails. So, when I
 check
 the table, I do not see the value of the changed field. I refreshed
 the
 table also but nothing. I printed the total value also to see if I
 was
 right and good. I do not know what is going wrong.
 Regards,
 Yessica

 2013/2/1 Fernand Vanrie s...@pmgroup.be

   Ariel, Yessica,

 with OObase database, table and field names are case sensitive,
 their
 is
 no need to quote if:  tables are lowercase and fieldnames uppercase.

 if quotes are used, then leave the dots out of the quotes
sSQL= SELECT mybase.cliente.**
 saldo_saldo_actual

 WHERE works

 greetz

 Fernand

On Thu, Jan 31, 2013 at 08:01:22PM -0300, Yessica Brinkmann
 wrote:

  Hi, thanks for your answer.

 Now I advanced.
 I print the value of the client code correctly.
 Only now I have another error, tells me that the Customer table
 does
 not
 exist or something like this:
 Basic runtime error. There was an exception. Type:
 com.sun.star.sdbc.**SQLException. Message: Table not found in
 statement

Re: Error in macro.

2013-02-03 Thread Yessica Brinkmann
Hello, sorry, I totally understand what you're saying and just tried to do
so. As I had said in my previous mail, when I try to change the default
saldo_actual field in the editing area of the Customer table, do not let me
Base.
You tell me:

- Edit the table customer: right click on the customer table, select
   Edit from the context menu. Edit the field saldo_actual, in
   Default value enter 0. Save the Table Design.

I've done that several times and does not allow me Base save the table, and
then the cursor is positioned right on the field saldo_actual.
We tried to do several things to see if it allowed me to make that change,
such as:

As much as I put in value If required, I deleted all records from the
customer table and Have even removed all relationships with Other tables,
just do not let me, I can not just save the change made and the cursor is
just saldo_actual field.

I do not know if I have a problem with my version of Open Office or what is
happening ... I am using Open Office 3.3.0
regards,
Yessica


2013/2/3 Ariel Constenla-Haile arie...@apache.org

 Hi Yessica,

 On Sun, Feb 03, 2013 at 02:58:58AM -0300, Yessica Brinkmann wrote:
  Hello,
  Excuse me please if I do a silly question. But the truth is that I could
  not change the default value of saldo_actual field from the cliente
 table.
  As much as I put in value If required, I deleted all records from the
  cliente table and have even removed all relationships with other tables,
  just do not let me, I can not just save the changes made and the cursor
 is
  just saldo_actual field. It seems very strange that there must be
 something
  I'm not understanding.
  Much appreciate an answer,

 I did it using the User Interface, though I guess that could also
 perform some SQL statements. In the user interface:

 - Edit the table cliente: right click on the cliente table, select
   Edit from the context menu. Edit the field saldo_actual, in
   Default value enter 0. Save the Table Design.

 - Open the table cliente: if you put the cursor on the last row, in
   order to insert a new record, you'll see that now saldo_actual is set
   to 0 automatically. For all the existing records (in the sample DB
   AURORA and OTRO CLIENTE) you will have to set it manually (or you can
   execute a SQL statement).

 - Open the form: your macro works now


 Regards
 --
 Ariel Constenla-Haile
 La Plata, Argentina



Re: Error in macro.

2013-02-02 Thread Yessica Brinkmann
Hello,
Yes, I write: SELECT cliente.saldo_actual FROM cliente WHERE id_cliente=0
and it works. It say: Command executed successfully.
The column name is saldo_actual , so I wrote in my last version of the
macro, which is in my previous mail.
Regards,
Yessica

2013/2/2 Fernand Vanrie s...@pmgroup.be

 Op 02/02/2013 07:04, Yessica Brinkmann schreef:

  Hello,
 I wanted to ask if I can please help with this issue. Is that really need
 to implement this functionality for my database. The macro has no errors
 but UPDATE is not performed in the customer table. I do not know if you
 owe
 the event in which I am putting my macro, event currently in the Mouse
 button released Calculate Total button. Same should work if saldo_actual
 field for a record is empty it?

 do the sql statement works when run from elsewhere (make a query to test)

 I also see that all new users first make an introduction, I'm doing my
 thesis on  Computer Engineering and I am working Independent, as do
 systems. I have more experience working on Java and XML, but I think this
 is a nice opportunity to learn Visual Basic.
 My macro is now as follows:
 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 rs As Object
 Dim sCliente as String
 Dim ColIndex as Integer
 '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
 rs=oFrm.createResultSet()
 sCliente=rs.getString(rs.**findColumn(cod_cliente))
 oTotal=oFrm.getByName(**fmttotal)
 Print sCliente
 Print oTotal.getCurrentValue()
 oCon=ThisDatabaseDocument.**CurrentController.**ActiveConnection
 oStat=oCon.CreateStatement
 sSQL = UPDATE cliente   SET cliente.saldo_actual = 
 
 cliente.saldo_actual +   oTotal.getCurrentValue()   WHERE
 cliente.id_cliente=  CInt(sCliente)
 oRes=oStat.ExecuteQuery(sSQL)
 End Sub
 Regards,
 Yessica
 2013/2/1 Yessica Brinkmann yessica.brinkm...@gmail.com

  Hello,
 I think maybe I should assign my macro to another event, perhaps one
 associated with the form to work, I do not know, my idea is just. Tempted
 now assigned to mouse button released event of a button called Calculate
 Total.
 regards,
 Yessica

 2013/2/1 Yessica Brinkmann yessica.brinkm...@gmail.com

  Hello,
 Thank you very much for the reply. Sorry, did not know that I should not
 put attachments. Now I have no errors in the macro, and I used the SQL
 UPDATE indicated. Just do not know why but UPDATE fails. So, when I
 check
 the table, I do not see the value of the changed field. I refreshed the
 table also but nothing. I printed the total value also to see if I was
 right and good. I do not know what is going wrong.
 Regards,
 Yessica

 2013/2/1 Fernand Vanrie s...@pmgroup.be

  Ariel, Yessica,

 with OObase database, table and field names are case sensitive, their
 is
 no need to quote if:  tables are lowercase and fieldnames uppercase.

 if quotes are used, then leave the dots out of the quotes
   sSQL= SELECT mybase.cliente.saldo_saldo_actual

 WHERE works

 greetz

 Fernand

   On Thu, Jan 31, 2013 at 08:01:22PM -0300, Yessica Brinkmann wrote:

 Hi, thanks for your answer.
 Now I advanced.
 I print the value of the client code correctly.
 Only now I have another error, tells me that the Customer table does
 not
 exist or something like this:
 Basic runtime error. There was an exception. Type:
 com.sun.star.sdbc.SQLException. Message: Table not found in
 statement

  This may need to quote table and fields names:

   sSQL=UPDATE cliente SET cliente.saldo_actual =

 cliente.saldo_saldo_actual +  oTotal.getCurrentValue()  WHERE
 cliente.id_cliente=  CInt(sCliente)

  What is the name of the table? CLIENTES or clientes?


 Regards






Re: Error in macro.

2013-02-02 Thread Ariel Constenla-Haile
On Sat, Feb 02, 2013 at 11:39:23PM -0300, Yessica Brinkmann wrote:
 Thank you for the answer! I put my database on mediafire, the link is as
 follows:
 http://www.mediafire.com/?bhzhr0zzkcz1iue
 The macro that I have problem is associated with the button Calcular Total
 on  Ventas form.

On a first quick look, your table cliente needs a default value of
0 in the field saldo_actual, otherwise it will fail in the UPDATE
statement when it is incremented.


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpCL6SqYh9ar.pgp
Description: PGP signature


Re: Error in macro.

2013-02-02 Thread Yessica Brinkmann
Hello,
Excuse me please if I do a silly question. But the truth is that I could
not change the default value of saldo_actual field from the cliente table.
As much as I put in value If required, I deleted all records from the
cliente table and have even removed all relationships with other tables,
just do not let me, I can not just save the changes made and the cursor is
just saldo_actual field. It seems very strange that there must be something
I'm not understanding.
Much appreciate an answer,
regards,
Yessica Brinkmann

2013/2/3 Ariel Constenla-Haile arie...@apache.org

 On Sat, Feb 02, 2013 at 11:39:23PM -0300, Yessica Brinkmann wrote:
  Thank you for the answer! I put my database on mediafire, the link is as
  follows:
  http://www.mediafire.com/?bhzhr0zzkcz1iue
  The macro that I have problem is associated with the button Calcular
 Total
  on  Ventas form.

 On a first quick look, your table cliente needs a default value of
 0 in the field saldo_actual, otherwise it will fail in the UPDATE
 statement when it is incremented.


 Regards
 --
 Ariel Constenla-Haile
 La Plata, Argentina



Re: Error in macro.

2013-02-01 Thread Fernand Vanrie

On 1/02/2013 0:01, Yessica Brinkmann wrote:

Hi, thanks for your answer.
Now I advanced.
I print the value of the client code correctly.
Only now I have another error, tells me that the Customer table does not
exist or something like this:
Basic runtime error. There was an exception. Type:
com.sun.star.sdbc.SQLException. Message: Table not found in statement
[UPDATE cliente]
there is no table cliente in the database were you are connected to in 
your case


ThisDatabaseDocument


Then I write my macro as it is now:
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 rs As Object
Dim sCliente as String
Dim ColIndex as Integer
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
rs=oFrm.createResultSet()
sCliente=rs.getString(rs.findColumn(cod_cliente))
oTotal=oFrm.getByName(fmttotal)
Print sCliente
oCon=ThisDatabaseDocument.CurrentController.ActiveConnection
oStat=oCon.CreateStatement
sSQL=UPDATE cliente SET cliente.saldo_actual =
cliente.saldo_saldo_actual +  oTotal.getCurrentValue()  WHERE
cliente.id_cliente=  CInt(sCliente)
oRes=oStat.ExecuteQuery(sSQL)
End Sub
Regards,
Yessica

2013/1/31 Fernand Vanrie s...@pmgroup.be


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 s...@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.brinkm...@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 and...@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 

Re: Error in macro.

2013-02-01 Thread Ariel Constenla-Haile
On Thu, Jan 31, 2013 at 08:01:22PM -0300, Yessica Brinkmann wrote:
 Hi, thanks for your answer.
 Now I advanced.
 I print the value of the client code correctly.
 Only now I have another error, tells me that the Customer table does not
 exist or something like this:
 Basic runtime error. There was an exception. Type:
 com.sun.star.sdbc.SQLException. Message: Table not found in statement

This may need to quote table and fields names:

sSQL=UPDATE cliente SET cliente.saldo_actual =
 cliente.saldo_saldo_actual +  oTotal.getCurrentValue()  WHERE
 cliente.id_cliente=  CInt(sCliente)

What is the name of the table? CLIENTES or clientes?


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpVW7wVmvYs2.pgp
Description: PGP signature


Re: Error in macro.

2013-02-01 Thread Yessica Brinkmann
Hello, thank you very much for the reply. The table name is cliente, as
shown in the print screen attached to my previous mail. Actually I tried
already to put quotes in many ways to the table names and columns but never
works for me.
Regards,
Yessica

2013/2/1 Ariel Constenla-Haile arie...@apache.org

 On Thu, Jan 31, 2013 at 08:01:22PM -0300, Yessica Brinkmann wrote:
  Hi, thanks for your answer.
  Now I advanced.
  I print the value of the client code correctly.
  Only now I have another error, tells me that the Customer table does not
  exist or something like this:
  Basic runtime error. There was an exception. Type:
  com.sun.star.sdbc.SQLException. Message: Table not found in statement

 This may need to quote table and fields names:

 sSQL=UPDATE cliente SET cliente.saldo_actual =
  cliente.saldo_saldo_actual +  oTotal.getCurrentValue()  WHERE
  cliente.id_cliente=  CInt(sCliente)

 What is the name of the table? CLIENTES or clientes?


 Regards
 --
 Ariel Constenla-Haile
 La Plata, Argentina



Re: Error in macro.

2013-02-01 Thread Fernand Vanrie

Ariel, Yessica,

with OObase database, table and field names are case sensitive, their is 
no need to quote if:  tables are lowercase and fieldnames uppercase.


if quotes are used, then leave the dots out of the quotes
 sSQL= SELECT mybase.cliente.saldo_saldo_actual 
WHERE works


greetz

Fernand

On Thu, Jan 31, 2013 at 08:01:22PM -0300, Yessica Brinkmann wrote:

Hi, thanks for your answer.
Now I advanced.
I print the value of the client code correctly.
Only now I have another error, tells me that the Customer table does not
exist or something like this:
Basic runtime error. There was an exception. Type:
com.sun.star.sdbc.SQLException. Message: Table not found in statement

This may need to quote table and fields names:


sSQL=UPDATE cliente SET cliente.saldo_actual =
cliente.saldo_saldo_actual +  oTotal.getCurrentValue()  WHERE
cliente.id_cliente=  CInt(sCliente)

What is the name of the table? CLIENTES or clientes?


Regards




Re: Error in macro.

2013-02-01 Thread Yessica Brinkmann
Hello,
I wanted to ask if I can please help with this issue. Is that really need
to implement this functionality for my database. The macro has no errors
but UPDATE is not performed in the customer table. I do not know if you owe
the event in which I am putting my macro, event currently in the Mouse
button released Calculate Total button. Same should work if saldo_actual
field for a record is empty it?
I also see that all new users first make an introduction, I'm doing my
thesis on  Computer Engineering and I am working Independent, as do
systems. I have more experience working on Java and XML, but I think this
is a nice opportunity to learn Visual Basic.
My macro is now as follows:
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 rs As Object
Dim sCliente as String
Dim ColIndex as Integer
'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
   rs=oFrm.createResultSet()
   sCliente=rs.getString(rs.findColumn(cod_cliente))
   oTotal=oFrm.getByName(fmttotal)
   Print sCliente
   Print oTotal.getCurrentValue()
   oCon=ThisDatabaseDocument.CurrentController.ActiveConnection
   oStat=oCon.CreateStatement
   sSQL = UPDATE cliente   SET cliente.saldo_actual =  
cliente.saldo_actual +   oTotal.getCurrentValue()   WHERE
cliente.id_cliente=  CInt(sCliente)
   oRes=oStat.ExecuteQuery(sSQL)
End Sub
Regards,
Yessica
2013/2/1 Yessica Brinkmann yessica.brinkm...@gmail.com

 Hello,
 I think maybe I should assign my macro to another event, perhaps one
 associated with the form to work, I do not know, my idea is just. Tempted
 now assigned to mouse button released event of a button called Calculate
 Total.
 regards,
 Yessica

 2013/2/1 Yessica Brinkmann yessica.brinkm...@gmail.com

 Hello,
 Thank you very much for the reply. Sorry, did not know that I should not
 put attachments. Now I have no errors in the macro, and I used the SQL
 UPDATE indicated. Just do not know why but UPDATE fails. So, when I check
 the table, I do not see the value of the changed field. I refreshed the
 table also but nothing. I printed the total value also to see if I was
 right and good. I do not know what is going wrong.
 Regards,
 Yessica

 2013/2/1 Fernand Vanrie s...@pmgroup.be

 Ariel, Yessica,

 with OObase database, table and field names are case sensitive, their is
 no need to quote if:  tables are lowercase and fieldnames uppercase.

 if quotes are used, then leave the dots out of the quotes
  sSQL= SELECT mybase.cliente.**saldo_saldo_actual
 WHERE works

 greetz

 Fernand

  On Thu, Jan 31, 2013 at 08:01:22PM -0300, Yessica Brinkmann wrote:

 Hi, thanks for your answer.
 Now I advanced.
 I print the value of the client code correctly.
 Only now I have another error, tells me that the Customer table does
 not
 exist or something like this:
 Basic runtime error. There was an exception. Type:
 com.sun.star.sdbc.**SQLException. Message: Table not found in
 statement

 This may need to quote table and fields names:

  sSQL=UPDATE cliente SET cliente.saldo_actual =
 cliente.saldo_saldo_actual +  oTotal.getCurrentValue()  WHERE
 cliente.id_cliente=  CInt(sCliente)

 What is the name of the table? CLIENTES or clientes?


 Regards







Re: Error in macro.

2013-01-31 Thread Fernand Vanrie

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.brinkm...@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 and...@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 and...@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 and...@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 

Re: Error in macro.

2013-01-31 Thread Fernand Vanrie

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 s...@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.brinkm...@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 and...@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 and...@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 and...@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 

Re: Error in macro.

2013-01-31 Thread Yessica Brinkmann
Hi, thanks for your answer.
Now I advanced.
I print the value of the client code correctly.
Only now I have another error, tells me that the Customer table does not
exist or something like this:
Basic runtime error. There was an exception. Type:
com.sun.star.sdbc.SQLException. Message: Table not found in statement
[UPDATE cliente]
Then I write my macro as it is now:
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 rs As Object
Dim sCliente as String
Dim ColIndex as Integer
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
   rs=oFrm.createResultSet()
   sCliente=rs.getString(rs.findColumn(cod_cliente))
   oTotal=oFrm.getByName(fmttotal)
   Print sCliente
   oCon=ThisDatabaseDocument.CurrentController.ActiveConnection
   oStat=oCon.CreateStatement
   sSQL=UPDATE cliente SET cliente.saldo_actual =
cliente.saldo_saldo_actual +  oTotal.getCurrentValue()  WHERE
cliente.id_cliente=  CInt(sCliente)
   oRes=oStat.ExecuteQuery(sSQL)
End Sub
Regards,
Yessica

2013/1/31 Fernand Vanrie s...@pmgroup.be

 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 s...@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.brinkm...@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 and...@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
 

Re: Error in macro.

2013-01-30 Thread Yessica Brinkmann
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 and...@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.odthttp://www.pitonyak.org/AndrewMacro.odt
 Info:  http://www.pitonyak.org/oo.php




Re: Error in macro.

2013-01-30 Thread Yessica Brinkmann
Hello,
I think I can do this with string functions Left and Split but I do not
know which is the separator for the ComboBox, for separating the code from
the name.
Much appreciate an answer please.
regards,
Yessica

2013/1/30 Yessica Brinkmann yessica.brinkm...@gmail.com

 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 and...@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.odthttp://www.pitonyak.org/AndrewMacro.odt
 Info:  http://www.pitonyak.org/oo.php





Re: Error in macro.

2013-01-30 Thread 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 and...@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.odthttp://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



Re: Error in macro.

2013-01-30 Thread Fernand Vanrie

 Yessica

nono , just check if the name of your controls are identical to what you 
call with getbyname (check uppercase, lower)


greetz

Fernand

Hello,
I think I can do this with string functions Left and Split but I do not
know which is the separator for the ComboBox, for separating the code from
the name.
Much appreciate an answer please.
regards,
Yessica

2013/1/30 Yessica Brinkmann yessica.brinkm...@gmail.com


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 and...@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.odthttp://www.pitonyak.org/AndrewMacro.odt
Info:  http://www.pitonyak.org/oo.php






Re: Error in macro.

2013-01-30 Thread Yessica Brinkmann
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 yessica.brinkm...@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 and...@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 and...@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 and...@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()