Results 1 to 6 of 6
  1. #1
    mcucino is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Jul 2017
    Location
    Providence, RI
    Posts
    74

    TableDefs syntaxt question

    Hi All, I'm trying to produce the field name of the 2nd field in a particular table. I am trying to figure out how to use indexing and tabledefs but I'm getting "Invalid operation. (Error 3219)". Help! Thanks



    Code:
      
    dim DestTable as string
    dim TheFieldName as string
    
    DestTable = "MyTable"
    TheFieldName = CurrentDb.TableDefs(DestTable).Fields(1)

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

  3. #3
    mcucino is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Jul 2017
    Location
    Providence, RI
    Posts
    74
    I actually just figured it out! all I needed was a .name at the end.

    I am trying to manage a sequence of years as columns in a data set and I needed to see what year came up first. The user can edit the table and add new years or remove years, so whatever year shows up first is the one I need.

    Now that I say that out loud, I realize it probably would be better to store a "start year" somewhere any time they change the table, but either way works, I suppose

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,413
    really sounds like your tables are not constructed properly and having users edit table design is a bad idea. A very excel way of thinking. By having a 'year' column you are building data into the table design.

  5. #5
    mcucino is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Jul 2017
    Location
    Providence, RI
    Posts
    74
    The changes to the table columns are handled by VBA with a form based on user input with lots of data validation and error handling. We spent a lot of time and effort determining the best database architecture for our needs and it's working very well so far. If we used your typical normalized table structure with a year it would be a nightmare of super slow crosstab queries on crosstab queries for 60 years worth of data. Although I am always open to suggestions and input.

  6. #6
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,413
    Without knowing the purpose of your dB and design constraints, not possible to suggest anything beyond normalisation considerations. I don’t propose to spend time trying to pursuade you to change something that works for you,

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

Similar Threads

  1. Fields property via TableDefs not recognized
    By GraeagleBill in forum Programming
    Replies: 8
    Last Post: 10-28-2015, 06:23 PM
  2. Item Not Found In Collection For TableDefs
    By gammaman in forum Modules
    Replies: 2
    Last Post: 06-17-2015, 07:55 AM
  3. tableDefs displaying Tables not there
    By JosmithTwo in forum Programming
    Replies: 3
    Last Post: 08-04-2012, 09:12 AM
  4. Working with TableDefs
    By farssr in forum Programming
    Replies: 2
    Last Post: 03-14-2011, 07:17 PM
  5. TableDefs.Delete
    By DaveE in forum Programming
    Replies: 3
    Last Post: 10-31-2010, 07:19 PM

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