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!
  • Students Click Here

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

Students Click Here

Microsoft: FoxPro FAQ

Databases and tables

Altering / Modifying Client Tables by jimoo
Posted: 3 Sep 03 (Edited 5 Sep 03)

See if the field ôcalcmethodö exist, add it if necessary.

* This is what the program does.
If [the field does not not exist on the table]
    If [able to add the field to the table]
        * Add the new field and continue
        * The field does not exist and unable to add it
        * Provide Error Message
    * Field exists already on table - no action required
    * Go On


* I like to add a date check to limit how long the code is executed.
* This is just in case I forget to take it out.
* It prevents unnessary opening / closing of tables over time.
IF DATE() < {08/01/2003}
    * The date-check provides plenty of time for the change to occur and stops
    * unnecessary opening / closing of tables if another version is not released
    * with this code commented out, or I forget to comment out the temporary code.

    SELECT 0
    USE joblist
    IF ASCAN(laFields,"CALCMETHOD") > 0
        * the field already exists
        * close the table, and go on our merry way
        * reopen it - this time exclusively so we can modify the structure
        USE joblist EXCL
        * The USE command closes the table (if necessary) and then tries to reopen it.  
        * Therefore, the table will not be open if the Exclusive-Use failed, even if
        * it were open prior to it.
        IF USED('joblist')
            * opened exclusively okay
            ALTER TABLE joblist ADD COLUMN calcMethod C(4) NOT NULL

            * now close it

            MESSAGEBOX("Update Successful!  -  The new CalcMethod field has been " +;

            * Houston, we have a problem.
            MESSAGEBOX("Update Failed!  -  Unable to add the new CalcMethod field " +;
                "because the joblist table cannot be opened exclusively at this time.  "+;
                "Have everyone exit the System and try it again.","MyClientName")




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

My Archive

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