Purpose : To setup the views captions etc after creating it as it exists in the related parent table
**********************************************************
** Set up the view Captions etc as in its parent TABLES.
**********************************************************
** by Subramanian.G (ramani)
** FoxAcc Software
** ramani_g@yahoo.com
** Last modified : 1st December, 2002
** provided as freeware
**********************************************************
** 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
*********************************************************
** Ramani (Subramanian.G), FoxAcc, ramani_g@yahoo.com
** Use at your risk.. No warranties or claims.
**********************************************************