Listbox Filter on Logical Field
- Greg Gammon
- Posts: 105
- Joined: Fri Jun 09, 2006 3:27 pm
- Location: Bryan, Texas
Listbox Filter on Logical Field
Greetings....
I have a Listbox that I want to show only items that are .t. for a logical field (field->template) in some views and all the data in another view.
Using the Set Filter command works but is slow. Ive tried to set up an Index on that logical field but am getting an index error.
INDEX ON field->template + field->custno where template is logical and custno is character. Can you do an Index on a logical field? Or is there a better way to accomplish what I am trying to do?
I would then use the SET SCOPE or SELECT function for the Listbox. Any guidance on this is appreciated!
Greg
I have a Listbox that I want to show only items that are .t. for a logical field (field->template) in some views and all the data in another view.
Using the Set Filter command works but is slow. Ive tried to set up an Index on that logical field but am getting an index error.
INDEX ON field->template + field->custno where template is logical and custno is character. Can you do an Index on a logical field? Or is there a better way to accomplish what I am trying to do?
I would then use the SET SCOPE or SELECT function for the Listbox. Any guidance on this is appreciated!
Greg
- Greg Gammon
- Posts: 105
- Joined: Fri Jun 09, 2006 3:27 pm
- Location: Bryan, Texas
Ok, that fixes the Index problem fine...thanks!
Next issue is the Listbox.
I use:
REDEFINE LISTBOX oLbx ..... SELECT estmain->template FOR .t. ;
In runtime, I get this ALERT message:
TWBrowse SetFilter() types don't match with current Index type.
You click OK on this Alert and the Listbox pops up and displays perfectly.
Other ideas? (or how to disable that Alert message?)
Thanks!
Greg
Next issue is the Listbox.
I use:
REDEFINE LISTBOX oLbx ..... SELECT estmain->template FOR .t. ;
In runtime, I get this ALERT message:
TWBrowse SetFilter() types don't match with current Index type.
You click OK on this Alert and the Listbox pops up and displays perfectly.
Other ideas? (or how to disable that Alert message?)
Thanks!
Greg
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Greg Gammon
- Posts: 105
- Joined: Fri Jun 09, 2006 3:27 pm
- Location: Bryan, Texas
- Greg Gammon
- Posts: 105
- Joined: Fri Jun 09, 2006 3:27 pm
- Location: Bryan, Texas
- Greg Gammon
- Posts: 105
- Joined: Fri Jun 09, 2006 3:27 pm
- Location: Bryan, Texas
- Greg Gammon
- Posts: 105
- Joined: Fri Jun 09, 2006 3:27 pm
- Location: Bryan, Texas
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
- Greg Gammon
- Posts: 105
- Joined: Fri Jun 09, 2006 3:27 pm
- Location: Bryan, Texas
ahhhh.....I did try ordscope but didn't take into account the exact length for cCustno.
Im not sure I exactly grasp the numerical indicator in the ordscope(0,...)
I tried using a 1 not sure what I was doing, so any explanation is helpful...the help files I read did not compute...laugh
I also did Ordscope(1, cAlias->...) Didn't think about the alias being outside ordscope. Why is that?
thanks!
G
Im not sure I exactly grasp the numerical indicator in the ordscope(0,...)
I tried using a 1 not sure what I was doing, so any explanation is helpful...the help files I read did not compute...laugh
I also did Ordscope(1, cAlias->...) Didn't think about the alias being outside ordscope. Why is that?
thanks!
G
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Greg,
Zero is the top scope--think of it as <=. One is the top scope, think of it as >=.
The alias here is not referring to the scope value (cCustno), but the scope function.
For safe programming force the var, cCustno, to be the length of the field:
cCustno:= padr(cCustno, len(field->custno))
This way if you ever change the length of the field it won't break your code.
James
Zero is the top scope--think of it as <=. One is the top scope, think of it as >=.
The alias here is not referring to the scope value (cCustno), but the scope function.
For safe programming force the var, cCustno, to be the length of the field:
cCustno:= padr(cCustno, len(field->custno))
This way if you ever change the length of the field it won't break your code.
James
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
I noticed that I made a syntax mistake, ordScope should be surrounded with parentheses like this:
(cAlias)->(ordScope(0,"T"+cCustno))
(cAlias)->(ordScope(1,"T"+cCustno))
You might also want to consider using database objects which frees you from using aliases and also provides lots of other benefits. There are a couple of articles about this on my website (see link button below).
(cAlias)->(ordScope(0,"T"+cCustno))
(cAlias)->(ordScope(1,"T"+cCustno))
You might also want to consider using database objects which frees you from using aliases and also provides lots of other benefits. There are a couple of articles about this on my website (see link button below).