Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need help on Grid
Message
From
29/09/1998 04:21:36
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
28/09/1998 15:32:56
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00141589
Message ID:
00141797
Views:
28
Hi Kelly,
First of all do a favor for yourself and change columnnames to some meaningfull ones instead of default column1..columnx (ie: custId, cmbColor...).
Do not set rowsources of combos in valid events, set them ,in init or form designer. If you have different combos based on some other value then use more than one combo and use column.dynamiccurrentcontrol.
* Your customer textbox valid - say name is txtCustId
IF !EMPTY(THIS.VALUE)
 TRNLST=SYS(2015)
 WITH THISFORM.GRID1.Column1.COMBO1
  .COLUMNCOUNT = 2
  .ROWSOURCETYPE = 3
  .RowSource = "SELECT PRODUCTID,DESCRIPTION FROM PRODUCT Order by    PRODUCTID WHERE PRODUCT.CUSTOMERID=THIS.VALUE INTO CURSOR    (M.TRNLST)"
  .Value = .ROWSOURCE
 ENDW
ENDIF

* Your prodcode.valid (This is column1.combo1.valid - right ?)
PRODI=SYS(2015)
  WITH THISFORM.GRID1.Column2.COMBO1
  .COLUMNCOUNT = 1
  .ROWSOURCETYPE = 3
  .RowSource = "SELECT PRODCOLOUR FROM PRODUCT Order by PRODCOLOUR    WHERE PRODUCT.PRODUCTID = THIS.VALUE INTO CURSOR (M.PRODI)"
  .Value = .ROWSOURCE
  ENDW

* Your productcolor.interactivechange
   stor Thisform.Grid1.COLUMN1.COMBO1.value+Thisform.GRID1.COLUMN2.
 COMBO1.value to rkey
 select  product
 set order to 3
 seek rkey
 if found()
  STOR PRICE to THISFORM.GRID1.COLUMN3.TEXT1.VALUE
 else
  STOR 0.00 to THISFORM.GRID1.COLUMN3.TEXT1.VALUE
 endif<hr>

* Change to
* As I got :
* Column1 -> Productcode and has combo    && Column1 renamed to cmbCode
* Column2 -> Productcolor and has combo   && Column2 renamed to cmbColor
* Column3 -> Productprice and has textbox && Column3 renamed to txtUnitPrice
* Grid.init
WITH THIS.cmbCode.COMBO1 && Change this column name to ie: cmbCode
  .COLUMNCOUNT = 2
  .ROWSOURCETYPE = 3
  .RowSource = "SELECT PRODUCTID,DESCRIPTION "+;
           "FROM PRODUCT "+;
           "WHERE "+;
               "CUSTOMERID=thisform.txtCustId.VALUE "+;
           "Order by "+
           "PRODUCTID "+;
           "INTO CURSOR prdCodes"
endwith

WITH THIS.cmbColor.COMBO1
  .COLUMNCOUNT = 1
  .ROWSOURCETYPE = 3
  .RowSource = "SELECT PRODCOLOUR "+;
     "FROM PRODUCT "+;
     "WHERE PRODUCT.PRODUCTID = this.parent.parent.cmbCode.value "+;
     "Order by PRODCOLOUR "+;
     "INTO CURSOR prdtColors"
ENDWith

* txtCustId.valid (or lostfocus which seem to be better)
THISFORM.GRID1.cmbCode.COMBO1.requery() && Repopulate combo
* thisform.grid1.cmbCode.COMBO1.valid
this.parent.parent.cmbColor.COMBO1.requery()

* thisform.grid1.cmbColor.interactivechange
* Better use tagname not number so you aren't limited to its indexorder

=seek(This.parent.parent.cmbCode.COMBO1.value+This.value,"product",3)
THIS.parent.parent.txtUnitPrice.TEXT1.VALUE = product.price

* With "set near off" as its default eof() would return 0 value
* I don't think but if you're allowing nulls
* then change this to if..else..endifCetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform