Solved

Function Find in DATAWINDOW

Posted on 2001-08-08
14
9,134 Views
Last Modified: 2013-12-26
sorry, my inglish is very poor. I Speak Spanish

Well

The problem is :

I have a DataWindow with any columns,  second column is the name and I want
find any name in the DataWindow.  I put the Single Line Edit and the Modify
Event Write this :

// Key_Pressed Script for sle_busca_nombre

long found_row, ll_largo

ll_largo = Len(sle_busca_nombre.text)

if Len(sle_busca_nombre.text) > 0 then       // Do case-insensitive search
      dw_1.SelectRow(0, FALSE)             // case-Sensitive search
      found_row = dw_1.Find("Pos(nombre_y_a, ~"" + sle_busca_nombre.text +
" )> 0 ~"", 1, 99999)

      // found_row = dw_1.Find("left(Lower(#2),ll_largo)= ~"" +
Lower(sle_busca_nombre.text) + "~"", 1, 99999)
     // found_row = dw_1.Find("Lower(#2) =~"" + Lower(sle_find.text) + "~"",
1, 99999)

     if found_row > 0 then
           dw_1.SetRow (found_row)
           dw_1.ScrollToRow(found_row)
           dw_1.SetRedraw(TRUE)
           dw_1.Show ()
     else // Filter function did not find any matching row
           Beep(3)
     end if

else  // Filter length is 0, so unhighlight former selected row
     dw_1.SelectRow(il_row, FALSE)
end if

il_row = found_row    // Remember number of highlighted row

**********************************************************

I try the find with other way (see comment line)  but the power send error
message when I'm use the Left o Pos function,  I like write part of the name and seek the name complet or the
firt name and so on.   THANKS for all.

0
Comment
Question by:pepe
  • 10
  • 3
14 Comments
 
LVL 4

Expert Comment

by:Bhatti
ID: 6367215
Try with simple script:

string ls_searchstr
long ll_row

//sle (singleLineEdit control is text control you need not to write .text)

ls_searchstr = "Pos(nombre_y_a,  + sle_busca_nombre +  " )> 0"

ll_row  = dw_1.Find(ls_searchstr, 1, dw_1.RowCount())

Do the same with second Find function where you use the left and lower functions.

May be text.text is the error

Try it and please let me know.






0
 
LVL 4

Expert Comment

by:Bhatti
ID: 6367432
Sorry pepe,

I just thought another a wrote only the SingleLineedit name and the .text.
You need it to write .text  for the text inside the sle.

ls_searchstr = "Pos(nombre_y_a,  + sle_busca_nombre.text +  " )> 0"

other remain the same.
0
 

Author Comment

by:pepe
ID: 6367997
I wrote your code in the Single Line Edit Event (Modify) and Display the Error message in runtime (expecting String expression)

****************** Your code *********************
string ls_searchstr
long ll_row

//sle (singleLineEdit control is text control you need not to write .text)

ls_searchstr = "Pos(nombre_y_a,"  + sle_busca_nombre.text +  " )> 0"

ll_row  = dw_1.Find(ls_searchstr, 1, dw_1.RowCount())

if ll_row > 0 then
     dw_1.SetRow (ll_row)
     dw_1.ScrollToRow(ll_row)
     dw_1.SetRedraw(TRUE)

     dw_1.Show ()
     
else     // Filter function did not find any matching row
     Beep(3)
end if

*********************************
Is possible to be necessary a quote(")in this sentence [ls_searchstr = "Pos(nombre_y_a,  + sle_busca_nombre.text +  " )> 0" ]   Before the first plus ?
The correct  sentence is this ? [ls_searchstr = "Pos(nombre_y_a,"  + sle_busca_nombre.text +  " )> 0" ]
0
 
LVL 4

Expert Comment

by:Bhatti
ID: 6368238
Hi pepe,

Sorry I did not checked the string:

I think it is so, this is the right syntex and you will get no error message.

look carefully and write in your script like this.

string ls_searchstring

ls_searchstring = "Pos(nombre_y_a,  ' "  + sle_busca_nombre.text    +  " ' "  + " ) > 0 "

ll_row  = dw_1.Find(ls_searchstr, 1, dw_1.RowCount())

if ll_row > 0 then
   dw_1.SetRow (ll_row)
   dw_1.ScrollToRow(ll_row)
   dw_1.SetRedraw(TRUE)
   dw_1.Show ()
                     
else     // Filter function did not find any matching row
    Beep(3)
 end if

I checked and it working. Please let me know THANKS
0
 
LVL 4

Expert Comment

by:Bhatti
ID: 6371393
Hallo Pepe,

Can you tell me that ls_searchstring working good and have no more error message.

THANKS
0
 
LVL 4

Expert Comment

by:Bhatti
ID: 6372951
I send you with change ls_string on 09.08.2001 07:35 AM PST.

ls_searchstring = "Pos(nombre_y_a,  ' "  + sle_busca_nombre.text    +  " ' "  + " ) > 0 "

Is it working good. Please let me know.

THANKS
0
 

Author Comment

by:pepe
ID: 6373423
Bhatti:
        Very very much, the function it's working ok. Thanks for your time.  keep in touch.

Regards,

Francisco Jose
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 4

Expert Comment

by:Bhatti
ID: 6379016
Hallo Francisco,

can you please grade this question?
What about Access Database Date Format Insert?


Bhatti
0
 

Author Comment

by:pepe
ID: 6381762
Bhatti :
          how are you ?  I'm try to insert in the Database Access but no more.  I'm puting the sentence so you give me :

******************************
DateTime  ldtm_hoy

ldtm_hoy = DateTime ( Today (), Now() )

INSERT INTO cuenta_corriente ( cuenta_corriente.fecha_inicio )
                        VALUES ( :ldtm_hoy ) ;

******************************
And the error message occurs.  I see when i save the Script, the PowerBuilder conecting to Database and the display error [SqlState]ODBC........

IF YOU KNOW ANY IDEA, PLEASE SAY ME.

Now I put the time in field type String and Date in field DateTime.

THANKS,  Francisco
0
 
LVL 4

Expert Comment

by:Bhatti
ID: 6385107
Sometimes datetime format is also with microseconds and I think you can also check by debuging the apllication (this script) and see the variable ldtm_hoy (format) and look also the format in the table.

******************************
  DateTime  ldtm_hoy

  ldtm_hoy = DateTime ( Today (), Now() )

  INSERT INTO cuenta_corriente ( fecha_inicio )
  VALUES ( :ldtm_hoy ) ;

******************************

How working the ODBC connection for other variables.
I think there must be format error or ODBC connection to Access error.

I was busy in changing some request in my project and got no time to write you. Write you tomarrow.
0
 
LVL 4

Accepted Solution

by:
Bhatti earned 50 total points
ID: 6388541
Hallo Francisco,

Writing you the as answer that working ok as you wrote.


string ls_searchstring
long ll_row

ls_searchstring = "Pos(nombre_y_a,  ' "  + sle_busca_nombre.text    +  " ' "  + " ) > 0 "

ll_row  = dw_1.Find(ls_searchstr, 1, dw_1.RowCount())

if ll_row > 0 then
   dw_1.SetRow (ll_row)
   dw_1.ScrollToRow(ll_row)
   dw_1.SetRedraw(TRUE)
   dw_1.Show ()
                                         
else     // Filter function did not find any matching row
   Beep(3)
end if

I think it is working good as you wrote me that function is working ok.
0
 
LVL 4

Expert Comment

by:Bhatti
ID: 6560374
Hallo Francisco,


Can you please friendly grad my answer. THANKS


Bhatti
0
 
LVL 4

Expert Comment

by:Bhatti
ID: 6689208
Hi Francisco,

Merry Christmas and a happy new year !!!


Best regards


Bhatti
0
 

Expert Comment

by:SpideyMod
ID: 8297071
Force Accepted

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now