Results 1 to 6 of 6
  1. #1
    xopherira is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2015
    Location
    Indiana
    Posts
    53

    check if column exist

    How do I check to see if column exist before adding it. New to VBA and having a problem testing for this condition.



    Public Sub keyColumn()

    DoCmd.RunSQL ("ALTER TABLE 3BSM_bom_template " & "ADD keyColumn COUNTER;")

    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    A db design that requires routine modification of table (adding fields) is probably not a normalized structure.

    Why do you need to programmatically add field? Why not just open table in design view and modify?

    Checking if field exists will probably require looping through table Field Collection.

    Bing: Access VBA does field exist in table

    http://forums.devarticles.com/micros...vba-58559.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    xopherira is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2015
    Location
    Indiana
    Posts
    53
    Its not a db per say. Im importing a very complicated spreadsheet and using access to manipulate with another spreadsheet. The structure of spreadsheets can not be changed.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    This is a periodic event?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    xopherira is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2015
    Location
    Indiana
    Posts
    53
    ONce a week at the most.

  6. #6
    InsuranceGuy is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Location
    Colorado
    Posts
    126
    If you're still wanting to check whether fields exist within a table, you'll want to take a look at the TableDefs DAO structures.

    You may also want to look at PowerQuery in Excel, depending on what you're trying to accomplish.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Check if record exist and update the status
    By JustinC in forum Access
    Replies: 4
    Last Post: 08-17-2014, 01:39 PM
  2. Check if record exist
    By sahand in forum Forms
    Replies: 2
    Last Post: 06-11-2014, 07:07 AM
  3. Replies: 3
    Last Post: 03-14-2012, 06:48 AM
  4. Check if record exist
    By khhess in forum Programming
    Replies: 1
    Last Post: 06-14-2011, 06:56 PM
  5. Check if value exist in a table
    By Lucas83 in forum Programming
    Replies: 2
    Last Post: 06-02-2010, 11:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums