Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing 2 character as 1 string 4

Status
Not open for further replies.

FoxWing

Programmer
Dec 20, 2004
44
GB
hi,

I'm stuck in trying to pass in a parameter below

do form search_form WITH 'H,L'

All the time,i pass in 1 character, but this time, i need to make it cater for more.


In my search_form (Init Method):
LPARAMETER w_special_acc <----- will receive H,L

thisform.grid1.recordsource = 'Select acc_no, desc1 from gl_ledger where INLIST(acc_type,w_special_acc)

Result, 'L' type is not selected.

Anything i miss ?
 
The "list' part of INLIST() needs to be a series of separate expressions. So rather than

do form search_form WITH 'H,L'

try

do form search_form WITH "'H','L'"


Jim
 
Jim,

Unfortunately, by applying
do form search_form WITH "'H','L'", i am now have no record selected.


Thanks
 
haven't tried this but may work:
Code:
thisform.grid1.recordsource = 'Select acc_no, desc1 from gl_ledger where INLIST(acc_type,[b][COLOR=blue]&[/color][/b]w_special_acc)'
let us know if this helped. peace! [peace]

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
If you use

do form search_form WITH "'H','L'"

then you'll need to say

thisform.grid1.recordsource = 'Select acc_no, desc1 from gl_ledger where INLIST(acc_type,&w_special_acc)

Jim
 
Using macro replacement in this way opens your program to a "code injection" vulnerability, expecially if the user is able to type the code to search for.

instead, I'd suggest this approach:

Code:
* Probably, the assignment of codes comes
*   out of an array, instead of individual var's like this.
lcCode1 = 'H' && this comes from somewhere else
lcCode2 = 'L' && this comes from somewhere else
lcCode3 = 'X' && this comes from somewhere else
lcCodes = lcCode1+lcCode2+lcCode3 && etc.

do form search_form WITH lcCodes

* In your search_form (Init Method):
LPARAMETER w_special_acc
* Store in form property so the SELECT can be refreshed
*   outside of .Init
* ( if you use the "form" menu to add the property, 
*    you don't have to add it here and can simply
*    assign it. )
THISFORM.addproperty('w_special_acc',w_special_acc)
thisform.grid1.recordsource = 'Select acc_no, desc1 from gl_ledger where acc_type $ THISFORM.w_special_acc'

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
My above suggestion assumes that gl_ledger.acc_type is a 1 character long field (which it seems to be from your code).

If it can be longer, then pad each code to the maximum length when creating lcCodes, and surround/separate them with commas:
Code:
lcCodes = ','
for lnI = 1 to aLen( laCodes, 1 )
  lcCodes = PADR(laCodes[lnI,1],5)+','
ENDFOR

and change the SELECT to:
Code:
thisform.grid1.recordsource = 'Select acc_no, desc1 from gl_ledger where ","+padr(acc_type,5)+"," $ THISFORM.w_special_acc'


- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Try this:

thisform.grid1.recordsource = 'Select acc_no, desc1 from gl_ledger where INLIST(acc_type,LEFT(w_special_acc,1),RIGHT(w_special_acc,1))'



 
Thanks guys.

With all your help, it finally works.

Once again, Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top