Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I base a textbox on an SQL statement?
Message
 
To
30/10/2000 20:23:43
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00436179
Message ID:
00436185
Views:
21
>Hi. I have a form with a grid. The grid shows products. I want to add a column to show the average days in the warehouse. My warehouse data contains a date so I want the SQL to be:
>select cpartno, avg(date()-indate) as avgdays from whcuinvbin group by 1 having cpartno = THISFORM.THISGRID.COLUMN1.txtPart.Value
>

You could use a UDF as your controlsource, but be warned, this could be slow if you have a lot of data. Put (Thisform.CalcAvg(cPartNo)) in the controlsource for the textbox (you need to have the outer parentheses, and create a form method called CalcAvg as follows:
function CalcAvg
lparameter tcPartNo

if type('tcPartNo') <> 'C'
   messagebox('Invalid parameter')
   return
endif

select cpartno, avg(date()-indate) as avgdays ;
   from whcuinvbin ;
   where cPartno = tcPartNo

return AvgDays
Since you're only pulling records for the one part number, you don't need a group by clause.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform