INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Databases and tables

Utility to set up the view Captions etc as in parent Tables. by ramani
Posted: 30 Nov 02

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.
**********************************************************

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close