filtering a list vfp

HI: I am writing a window purchase order system in vfp. The components I have grouped in codes in a table called tips.dbf.
 So I have say  'CLR', 'PAT' 'SOF',  for Glass, 'SPA',"SWS' "WRM' for spacer bar etc.  A list on a form displays all of these codes .When you select a code from the list (say CLR) a grid is populated with all the components in that code. Works great. However there are a lot of codes.
So these codes are themselves grouped by type (in a  second field in the table) - so all glass related groups are given a  group'1'; all spacer related components are group '2', etc.
I would like to be able to filter the list so that if somebody wanted to order a glass component, only the codes in that group are visible. Thus if you want to order glass, click a button and the list only displays  those codes in group 1.
I have this in a button:
"SELECT tips
SET FILTER TO group = 1
Thisform.List1.refresh"
Which kind of works until I select from the list at which point the list becomes readonly, some codes disappear, or other odd things occur. And I often (not always!) get a message 'thisform can only be used within a method'
This is the code when I click on the list:
'SET FILTER TO orderbase.Type = Thisform.lIST1.Value
THISFORM.grid1.Refresh'
where order base is the table of components , reading in grid1.
I am obviously dead wrong here - anybody know the dead right way?
And I recognise that somebody may want to reset the filter to a different group so deleting from table 'tips' is a no go!
Thanks!
Richard TeasdaleFinancial ControllerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pcelbaCommented:
1) You should use  Thisform.List1.Requery  after the Filter definition

2) SET FILTER TO orderbase.Type = Thisform.lIST1.Value
is correct when the form exists and when you are still inside this form which is not always true.  Once you call some external procedure from the form or for whatever reason the form becomes "out of focus" the THISFORM is not valid and the filter is cleared after the error message "THISFORM can only..."
 
So instead of
SET FILTER TO orderbase.Type = Thisform.lIST1.Value
use macro substitution (suppose the Thisform.lIST1.Value is numeric without decimal places):
LOCAL lcMacro
lcMacro = ALLTRIM(STR(Thisform.lIST1.Value))
SET FILTER TO orderbase.Type = &lcMacro

If the Thisform.lIST1.Value is not numeric then you have to update the macro string creation appropriately, e.g. Character data type:
lcMacro = ALLTRIM(Thisform.lIST1.Value)
SET FILTER TO orderbase.Type = "&lcMacro"

You could also use global variable for the filter definition but it is not necessary here. The filter defined with macro substitution is fully independent.
0
Richard TeasdaleFinancial ControllerAuthor Commented:
I knew it would be you!
Many thanks - yet again!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Richard TeasdaleFinancial ControllerAuthor Commented:
...and no, I have not even bothered to check; that is how much I trust you!
0
Richard TeasdaleFinancial ControllerAuthor Commented:
Expert answer as usual
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
FoxPro

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.