+ Reply to Thread
Results 1 to 10 of 10

VBA: Getting list of TableName/FieldName

  1. #1
    Forum Contributor
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    417

    VBA: Getting list of TableName/FieldName

    Is it possible to write VBA code to get table name and field name from database?

    For example, if I have Sybase database abc, and I would like to list all tables and fields in sheet Output, something like below screenshot.

    Is it possible? If yes, how to complete my code?

    Thanks.

    Please Login or Register  to view this content.
    Attached Images Attached Images

  2. #2
    Registered User
    Join Date
    10-08-2020
    Location
    Sakarya, Türkiye
    MS-Off Ver
    Office 2019 - x64
    Posts
    3

    Re: VBA: Getting list of TableName/FieldName

    You can access this information by using the "ADOX (Microsoft ADO Ext. 2.8 / 6.0 DDL and Security)" library.
    Please search web or MS documents.
    Blog : https://zekigursoy.blogspot.com

  3. #3
    Forum Contributor
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    417

    Re: VBA: Getting list of TableName/FieldName

    Quote Originally Posted by Zeki Gürsoy View Post
    You can access this information by using the "ADOX (Microsoft ADO Ext. 2.8 / 6.0 DDL and Security)" library.
    Please search web or MS documents.
    Then how should I finish remaining code?

    Thanks.

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    2016 primarily
    Posts
    6,444

    Re: VBA: Getting list of TableName/FieldName

    You could use a routine like this - just pass it a connection object and a cell to start the output in:

    Please Login or Register  to view this content.
    Rory
    I drink, and I know things

  5. #5
    Forum Contributor
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    417

    Re: VBA: Getting list of TableName/FieldName

    Quote Originally Posted by rorya View Post
    You could use a routine like this - just pass it a connection object and a cell to start the output in:

    Please Login or Register  to view this content.
    Thanks for the code, how can your code be merged into my existing code? I would like to write the result in the sheet "Output"?

  6. #6
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    2016 primarily
    Posts
    6,444

    Re: VBA: Getting list of TableName/FieldName

    After adding that code as a separate routine, replace your red line with:

    Please Login or Register  to view this content.
    for example.

  7. #7
    Forum Contributor
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    417

    Re: VBA: Getting list of TableName/FieldName

    Quote Originally Posted by rorya View Post
    After adding that code as a separate routine, replace your red line with:

    Please Login or Register  to view this content.
    for example.
    Thanks so much for the code, in general, it works.

    I have changed a1 to a2, since I would like to reserve cell A1 and B1 for heading cells "Table Name" & "Column Name".

    Highlighted green area is the output from your code, could you please modify your code to make the output looking like the highlighted yellowed area (without empty cells in between)? If not, I can write separate code to delete/shift up cells.

    Thanks.
    Attached Images Attached Images

  8. #8
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    2016 primarily
    Posts
    6,444

    Re: VBA: Getting list of TableName/FieldName

    You could use:

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    417

    Re: VBA: Getting list of TableName/FieldName

    Thanks so much.

  10. #10
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    2016 primarily
    Posts
    6,444

    Re: VBA: Getting list of TableName/FieldName

    Glad to help, and thanks for the rep

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. GETPIVOTDATA #REF Error linking to FieldName to Cell
    By ptmuldoon in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-10-2020, 07:49 PM
  2. Change tablename on basis of cell value
    By sanjuss2 in forum Excel General
    Replies: 9
    Last Post: 05-12-2017, 08:01 AM
  3. INSERT INTO tablename using sql [dynamic table?]
    By swill008 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-18-2013, 10:22 AM
  4. sum multiple cells in the same row that are in colums with the same fieldname
    By johnnymac1971 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-13-2012, 05:24 PM
  5. Pivot Table Fieldname
    By haydeeho in forum Excel General
    Replies: 0
    Last Post: 04-30-2008, 11:45 AM
  6. How to know Rank Of FieldName ??
    By Samary in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 04-25-2006, 11:30 PM
  7. Save file as filename plus fieldname
    By annep in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-18-2005, 07:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1