Solved

filtering a list vfp

Posted on 2014-10-22
4
182 Views
Last Modified: 2015-02-17
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!
0
Comment
Question by:ClaytonGlass
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 42

Expert Comment

by:pcelba
ID: 40396583
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
 

Accepted Solution

by:
ClaytonGlass earned 0 total points
ID: 40396588
I knew it would be you!
Many thanks - yet again!
0
 

Author Comment

by:ClaytonGlass
ID: 40396591
...and no, I have not even bothered to check; that is how much I trust you!
0
 

Author Closing Comment

by:ClaytonGlass
ID: 40613812
Expert answer as usual
0

Featured Post

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
In this blog we highlight approaches to managed security as a service.  We also look into ConnectWise’s value in aiding MSPs’ security management and indicate why critical alerting is a necessary integration.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

717 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