Click here to save this page

** Utility to set up the view Captions as in parent Tables.



** Utility to set up the view Captions as in parent Tables.
*********************************************************
** Author   : Ramani (Subramanian.G)
**            FoxAcc Software / Winners Software
** Type     : Freeware with reservation to Copyrights
** Warranty : Nothing implied or explicit
*********************************************************
** How to use ....
** 1. Copy this as SetView.PRG as given below
** 2. Open up your project in your project manager
** 3. Run the programme 'DO setView' from the command window
**    OR in the command window enter  =SetView()
** 4. Answer the question for View Name and Select the DBC.
*********************************************************
** PROCEDURE SetView
LOCAL cSQL, nTables, tTable1, tVIew1, tText
LOCAL laView1, lnItems, lcField
DECLARE laView1(1,1)

tView1 = INPUTBOX("Specify View Name whose properties are to be set ")
tView1 = ALLTRIM(tView1)

IF EMPTY(tView1)
   MESSAGEBOX("Table name or View name missing",0+16, ;
              "Cannot continue")
   RETURN
ENDIF

OPEN DATABASE ?

cSQL = ""
cSQL = DBGETPROP(tView1,"VIEW","SQL")
nTables = OCCURS("!",cSQL)

IF nTables = 0
   MESSAGEBOX("Table name or View name missing",0+16,;
         "Cannot continue")
   RETURN
ENDIF

IF ! USED("tView1")
   USE (tView1) IN 0 ALIAS tView1
ENDIF
lnItems = AFIELDS(laView1, "tView1")

tText = SUBSTR(cSQL,ATC("!",cSQL)+1)

ON ERROR DO myViewError
FOR x = 1 TO nTables
   tTable1 = LEFT(tText,ATC(" ",tText)-1)

   FOR y = 1 TO lnItems
      lcField = ALLTRIM(laView1(y,1))
      DBSETPROP(tView1+"."+lcField,"FIELD","CAPTION", ;
         DBGETPROP(tTable1+"."+lcField,"FIELD","CAPTION"))
   ENDFOR
   tText = SUBSTR(tText,ATC("!",tText)+1)
ENDFOR
USE IN tView1
ON ERROR
RETURN
*********************************************************
FUNCTION myViewError
    RETURN
ENDPROC
*********************************************************
** EOF
*********************************************************

Home       Feedback       DataBase       VisualFoxProFAQ