locked
How to view necessary things only in Relation with Skip command ? RRS feed

  • Question

  • TranFile
    ID,  AMT
    10 700
    25 1500
    10  600

    CodeFile
    ID,  NAME
    10 Rajesh
    5 Amar
    15 Suresh
    17 Mahesh
    25 Bihari

    SELECT 0
     USE TranFile ALIAS TranAlias
     Index on ID to TranFile

    SELECT 0
     USE CodeFile ALIAS CodeAlias
     INDEX on NAME TO CodFile

     SET RELATION TO ID INTO TranAlias
     SET SKIP TO TranAlias

    Browse fields TranAlias.ID, CodeAlias.NAME, TranAlias.AMT
         Amar
    25 Bihari          1500
         Mahesh
    10 Rajesh        700
    10 ********  600
         Suresh  

    BUT, I WANT only view:
    25 Bihari      1500
    10 Rajesh     700
    10 *******  600

    How to do this ?

    Friday, June 28, 2013 6:24 AM

Answers

  • No, you cannot change asterisks to something else in relation.

    It is really time to start with SQL... 

    SELECT TranAlias.ID, CodeAlias.NAME, TranAlias.AMT ;
      FROM TranAlias ;
      INNER JOIN CodeAlias ON CodeAlias.ID = TranAlias.ID ;
      ORDER BY CodeAlias.NAME ;
      INTO CURSOR cJoinedData READWRITE

    *-- And now you may replace the multiple occurrences of the NAME by whatever you want:
    LOCAL lcLastName SELECT cJoinedData lcLastName = 'x' + NAME SCAN IF NAME == m.lcLastNae REPLACE NAME WITH "++++++" ELSE lcLastNae = NAME ENDIF ENDSCAN BROWSE

    You should also test LEFT JOIN and other possibilities of the SQL language.

    • Marked as answer by A.Ankit Saturday, June 29, 2013 1:35 PM
    Friday, June 28, 2013 2:54 PM
  • You may try:

    Browse fields TranAlias.ID, CodeAlias.NAME, TranAlias.AMT FOR !EOF("TranAlias")


    Of course, I would recommend to create a cursor by SQL query and display the cursor in a grid (or BROWSE).
    • Edited by Pavel Celba Friday, June 28, 2013 6:38 AM More info
    • Marked as answer by A.Ankit Friday, June 28, 2013 7:05 AM
    Friday, June 28, 2013 6:36 AM

All replies

  • You may try:

    Browse fields TranAlias.ID, CodeAlias.NAME, TranAlias.AMT FOR !EOF("TranAlias")


    Of course, I would recommend to create a cursor by SQL query and display the cursor in a grid (or BROWSE).
    • Edited by Pavel Celba Friday, June 28, 2013 6:38 AM More info
    • Marked as answer by A.Ankit Friday, June 28, 2013 7:05 AM
    Friday, June 28, 2013 6:36 AM
  • Thank you Pavel.
    your suggestion works successfully.

    But now, I want to use it In Grid Class

    Where to write code  [ FOR !EOF("TranAlias")  ]   in Grid

    *********************************************************************
    SELECT 0
     USE TranFile ALIAS TranAlias
     Index on ID to TranFile

    SELECT 0
     USE CodeFile ALIAS CodeAlias
     INDEX on NAME TO CodFile

     SET RELATION TO ID INTO TranAlias
     SET SKIP TO TranAlias

                   SET FILTER TO ! EOF("TranAlias") 

                    ** Is this the Right Logic ???

     **  Browse fields TranAlias.ID, CodeAlias.NAME, TranAlias.AMT FOR !EOF("TranAlias")

    frm1 = CREATEOBJECT('frm1_Clas')
    frm1.SHOW
    READ EVENTS

    DEFINE CLASS frm1_Clas AS form
     ADD OBJECT GridClass AS Grid_Class
    ENDDEFINE

    DEFINE CLASS Grid_Class As Grid
     Height  = 250
     width  = 400
     ColumnCount = 3
     
     **************
     Procedure INIT
      THIS.RecordSource = "CodeAlias"

      ****************
      THIS.Column1.Name = "colID"
      With THIS.colID
       .ControlSource= "TranAlias.ID"
       .HEADER1.CAPTION= "ID"
       ENDWITH
      THIS.Column2.Name = "colName"
      With THIS.colName
       .ControlSource= "CodeAlias.NAME"
       .HEADER1.CAPTION= "NAME"
       ENDWITH
      THIS.Column3.Name = "colAMT"
      With THIS.colAMT
       .ControlSource= "TranAlias.AMT"
       .HEADER1.CAPTION= "AMT"
       ENDWITH

    ENDDEFINE

    *******************************************

    And The Second Question is:

    Can we change the ****** in to other Character / or / By control Fade Color in Grid

    25 Bihari      1500
    10 Rajesh     700
    10 *******  600   <<----


    • Edited by A.Ankit Friday, June 28, 2013 9:30 AM correction
    Friday, June 28, 2013 7:39 AM
  • No, you cannot change asterisks to something else in relation.

    It is really time to start with SQL... 

    SELECT TranAlias.ID, CodeAlias.NAME, TranAlias.AMT ;
      FROM TranAlias ;
      INNER JOIN CodeAlias ON CodeAlias.ID = TranAlias.ID ;
      ORDER BY CodeAlias.NAME ;
      INTO CURSOR cJoinedData READWRITE

    *-- And now you may replace the multiple occurrences of the NAME by whatever you want:
    LOCAL lcLastName SELECT cJoinedData lcLastName = 'x' + NAME SCAN IF NAME == m.lcLastNae REPLACE NAME WITH "++++++" ELSE lcLastNae = NAME ENDIF ENDSCAN BROWSE

    You should also test LEFT JOIN and other possibilities of the SQL language.

    • Marked as answer by A.Ankit Saturday, June 29, 2013 1:35 PM
    Friday, June 28, 2013 2:54 PM
  • Pavel Sir, Thank you once again for your answers.

    I am new in SQL statement, But I am interested to work with SQL

    Trn_Yr12 ( Transaction
    ID,  Dt,       Amt
    10   15/6/12   300
    15   25/7/12   500
    25   16/8/12   850

    Trn_Yr13  (Transaction
    ID,  Dt,      Amt
    10   10/4/13  200
    15   12/4/13  750

    IdFile
    ID,  Name
    10   Ramesh
    15   Suresh


    I want to View ID which is 10
    10  Ramesh  15/6/12   300
    10  Ramesh  10/4/13   200

    How to code to View Data using with Grid Class and Using SQL Statement

    Please help me.

    Saturday, June 29, 2013 1:41 PM
  • You learn SQL here: http://www.w3schools.com/sql/ or here: http://www.sqlcourse.com/index.html

    These FoxPro videos are also good: http://www.garfieldhudson.com/freevideos.aspx

    The simplest way how to display data in a grid is to create an empty form by CREATE FORM YourForm command, then place a grid to the form and call the form by DO FORM YourForm.  The grid on a form will display data from currently open table.

    Your way of grid class definition is also possible but it is more advanced.

    Saturday, June 29, 2013 2:03 PM