Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Rearranging data on grid
Message
From
27/10/2005 03:34:39
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP1
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01062234
Message ID:
01062522
Views:
13
>I was wondering whether its possible to re-arrange data from a table into a grid in the following manner. I have a typical result set like below:
>
>
>Style             Activity            Actual Date
>--------------------------------------------------
>JKT001            Costed              19/10/2005
>JKT001            Cut                 20/10/2005
>JKT001            Made                21/10/2005
>JKT002            Costed              23/10/2005
>JKT002            Cut                 24/10/2005
>JKT002            Made                26/10/2005
>
>
>I would like to display this to a grid using the activities as the column headers:
>
>
>
><pre>
>Style             Costed         Cut          Made
>------------------------------------------------------
>JKT001          19/10/2005    20/10/2005    21/10/2005
>JKT002          23/10/2005    24/10/2005    26/10/2005
>
>
>Is this possible basically using the activities as the column headers and rearranging the dates??
>
>The activities will never change!!

Neil,
If activities would never change:
Public oForm
oForm = Createobject('myForm')
oForm.Show

Define Class myForm As Form
  Height = 300
  Width = 400
  DataSession = 2
  Add Object myGrid As Grid With Height = 300,Width=400

  Procedure Init
  	Set Nulldisplay To ''
    Local lcSQL
TEXT to m.lcSQL noshow
  Select distinct a.Style, ;
	b.ActualDate as 'Costed', ;
	c.ActualDate as 'Cut', ;
	d.ActualDate as 'Made' ;
	from __mySource a ;
		left join __mySource b on a.Style == b.Style and b.Activity == 'Costed' ;
		left join __mySource c on a.Style == c.Style and c.Activity == 'Cut' ;
		left join __mySource d on a.Style == d.Style and d.Activity == 'Made' ;
	into cursor myGridSource && readwrite
ENDTEXT
    m.lcSQL = Alltrim(Chrtran(m.lcSQL,Chr(9)+';'+Chr(13)+Chr(10),Space(2)))
    With This.myGrid
      .RecordSourceType = 4
      .RecordSource = m.lcSQL
    Endwith
  Endproc
Enddefine
If you enable editing remember you're doing it in a cursor.
Cetin
Ç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
Reply
Map
View

Click here to load this message in the networking platform