General discussion

  • Creator
    Topic
  • #2259085

    MS ACCESS Table update

    Locked

    by ashishab ·

    How do I add new fields to existing access table. I would like to varify the field, If it does not exixst add the field,

All Comments

  • Author
    Replies
    • #3205692

      Reply To: MS ACCESS Table update

      by john.a.wills ·

      In reply to MS ACCESS Table update

      Open the table in design mode. Write in the new columns as rows in the design. Close the table – or switch to data mode and see the new, empty columns. You can also use this procedure to alter types, but be warned that you may lose data this way.

    • #3199004

      Reply To: MS ACCESS Table update

      by wayne m. ·

      In reply to MS ACCESS Table update

      I am assuming you want to do this programmatically in VBA.

      To verify if the column exists, use a COUNT(columnName) FROM tableName and catch the error. If the column does not exist, the script will throw an error; catch the error and set a flag one way. Otherwise, the routine will run normally. This is a slow and inefficient approach, so if someone knows a better way, please suggest it!

      To add a column, use ALTER TABLE – ADD COLUMN. One online reference is http://www.w3schools.com/sql/sql_alter.asp Google for some more. There are also lots of SQL books out there, but the MS Access Jet database only supports a limited subset of standard SQL.

      I do not know your familiarity with ADO or DAO programming, but if this is not your comfortable approach, you may want to use the visual tools described in the previous answer.

Viewing 1 reply thread