{"id":1180,"date":"2016-08-07T21:37:14","date_gmt":"2016-08-08T01:37:14","guid":{"rendered":"http:\/\/regina-whipp.com\/blog\/?p=1180"},"modified":"2018-07-18T22:35:46","modified_gmt":"2018-07-19T02:35:46","slug":"list-tables-and-fields","status":"publish","type":"post","link":"https:\/\/regina-whipp.com\/blog\/?p=1180","title":{"rendered":"List Tables and Fields&#8230;"},"content":{"rendered":"<p>When I&#8217;m designing a database I usually start off with one of my Templates. But, as with any Template, the Tables therein do not always fit exactly with the Client&#8217;s needs. And, since I like to document changes I built this tool&#8230;<\/p>\n<p><span style=\"color: #000000; font-family: Segoe UI; font-size: small;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-956\" src=\"http:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2016\/07\/TableFieldList.png\" alt=\"\" width=\"903\" height=\"517\" \/><\/span><\/p>\n<p>In a nutshell&#8230;<br \/>\nAfter the Template database is created I import the Objects from the <a href=\"http:\/\/www.access-diva.com\/myzipfiles\/TableFieldList.zip\" target=\"_blank\" rel=\"noopener\">Tables and File List<\/a> database. From there I can go to Design Mode of the Table, the little blue button, and make my changes, as well as, mark what changes I&#8217;ve made in the *Comments* column. Then I have a record of my changes and, just in case someone needs a hard copy, output the results to Excel (template included).<\/p>\n<p>To use&#8230;<br \/>\nDownload the <a href=\"http:\/\/www.access-diva.com\/myzipfiles\/TableFieldList.zip\" target=\"_blank\" rel=\"noopener\">Table and File List<\/a> zipped file and unzip the contents to a Folder, not your Desktop. Then open the database you want to run this on and import the Objects into your database and place<strong> TableFieldList.xlsx<\/strong> into the same Folder as the database you want to use this in. Open <strong>frmTableFileList<\/strong> and click the <strong>Redo<\/strong> Command Button.<\/p>\n<p>The blue button to the left opens the <strong>Table<\/strong> in <strong>Design Mode<\/strong>. (Thanks to <a href=\"http:\/\/www.granite.ab.ca\/access\/ensuringuniformcontrolwidth.htm\" target=\"_blank\" rel=\"noopener\">Tony Toews&#8217; database<\/a> for giving me the idea to go directly to Design Mode from here instead to dealing with the Navigation Pane.)<\/p>\n<p>I use the <strong>Check Box<\/strong> to indicate I cam done. Once checked the record (row) will turn light grey (helps me stay focused).<\/p>\n<p>Blue boxes at the top are for filtering. Once making a selection and\/or entering text, partial entries accepted, select the <strong>Filter<\/strong> button at the top, to clear select the <strong>Clear Filter<\/strong> button.<\/p>\n<p>The code (in case your interested)&#8230;<br \/>\nPretty standard except that it loops thru the Tables in MSysObjects so it does not require the individual input of each Table run. Nor do you need to create tblTableFieldList before running as it will look to see if it&#8217;s there. (One caveat, I did not adjust the Form to run without the query which needs the Table, never got around to it. So, if you attempt to open the Form before creating the Table you will get a message. However, in the sample provided there is a Table so no worries there.)<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">Function fncTableFieldList()\r\n'7.15.2016 Gina Whipp (Access Diva)\r\n'Purpose:  Write all table and field names to tblTableFieldList\r\n     \r\n    Dim lngTable As Long\r\n    Dim lngField As Long\r\n    Dim db As DAO.Database\r\n    Dim rs As DAO.Recordset\r\n    Dim tdf As DAO.TableDef\r\n    Dim lngRow As Long\r\n    Dim fld As DAO.Field\r\n    Dim strTable As String\r\n    \r\n        Set db = CurrentDb\r\n        \r\n        strTable = &quot;tblTableFieldList&quot;\r\n        \r\n        If DCount(&quot;*&quot;, &quot;MSysObjects&quot;, &quot;Type = 1 AND Name='&quot; &amp; strTable &amp; &quot;'&quot;) = 0 Then\r\n            'Create tblTableFieldList\r\n            Set tdf = db.CreateTableDef(&quot;tblTableFieldList&quot;)\r\n\r\n        With tdf\r\n           'Autonumber\r\n           Set fld = .CreateField(&quot;tflID&quot;, dbLong)\r\n           fld.Attributes = dbAutoIncrField + dbFixedField\r\n              .Fields.Append fld\r\n              \r\n              .Fields.Append .CreateField(&quot;tflTableName&quot;, dbText, 50)\r\n              .Fields.Append .CreateField(&quot;tflFieldName&quot;, dbText, 50)\r\n              .Fields.Append .CreateField(&quot;tflDataTypeID&quot;, dbLong)\r\n              .Fields.Append .CreateField(&quot;tflSize&quot;, dbLong)\r\n              .Fields.Append .CreateField(&quot;tflAttributeID&quot;, dbLong)\r\n              .Fields.Append .CreateField(&quot;tflComment&quot;, dbText, 255)\r\n              .Fields.Append .CreateField(&quot;tflExclude&quot;, dbBoolean)\r\n        End With\r\n            'Append new output table definition to database\r\n            db.TableDefs.Append tdf\r\n            Set fld = Nothing\r\n            Set tdf = Nothing\r\n            'Debug.Print &quot;tblTableFieldList created.&quot;\r\n            Application.RefreshDatabaseWindow\r\n        Else\r\n            'Empty tblTableFieldList\r\n            strSQL = &quot;DELETE tblTableFieldList.* FROM tblTableFieldList&quot;\r\n                      CurrentDb.Execute strSQL, dbFailOnError\r\n            'Debug.Print &quot;tblTableFieldList emptied.&quot;\r\n        End If\r\n        \r\n        Set rs = db.OpenRecordset(&quot;tblTableFieldList&quot;, dbOpenDynaset)\r\n    'Set on error in case there is no tables\r\n    On Error Resume Next\r\n    \r\n    'Loop through all tables\r\n    For lngTable = 0 To db.TableDefs.Count\r\n        'Ignore temporary (~) and system tables (MSys)\r\n        If Left(db.TableDefs(lngTable).Name, 1) = &quot;~&quot; Or _\r\n            Left(db.TableDefs(lngTable).Name, 4) = &quot;MSys&quot; Then\r\n        Else\r\n            'Otherwise, loop through each table and get Primary Key\r\n            For lngField = 0 To db.TableDefs(lngTable).Fields.Count - 1\r\n            'Use this if you don't want Primary Key\r\n            'For lngField = 1 To db.TableDefs(lngTable).Fields.Count - 1\r\n                lngRow = lngRow + 1\r\n                    rs.AddNew\r\n                    rs!tflTableName = db.TableDefs(lngTable).Name\r\n                    rs!tflFieldName = db.TableDefs(lngTable).Fields(lngField).Name\r\n                    rs!tflDataTypeID = db.TableDefs(lngTable).Fields(lngField).Type\r\n                    rs!tflSize = db.TableDefs(lngTable).Fields(lngField).Size\r\n                    rs!tflAttributeID = db.TableDefs(lngTable).Fields(lngField).Attributes\r\n                    rs.Update\r\n            Next lngField\r\n        End If\r\n    Next lngTable\r\n    'Resume error breaks\r\n    On Error GoTo 0\r\n     \r\n    'Release from memory\r\n    Set rs = Nothing\r\n    Set db = Nothing\r\n     \r\nEnd Function\r\n <\/pre>\n<p>Enjoy!<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_1180\" class=\"pvc_stats all  \" data-element-id=\"1180\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/regina-whipp.com\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>When I&#8217;m designing a database I usually start off with one of my Templates. But, as with any Template, the Tables therein do not always fit exactly with the Client&#8217;s needs. And, since I like to document changes I built this tool&#8230;<\/p>\n<\/p>\n<p>In a nutshell&#8230; After the Template database is created I import the [&#8230;]<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_1180\" class=\"pvc_stats all  \" data-element-id=\"1180\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/regina-whipp.com\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,63],"tags":[64,18,40],"class_list":["post-1180","post","type-post","status-publish","format-standard","hentry","category-access-tips","category-database-design","tag-access-tips","tag-database-design","tag-table-design","odd"],"a3_pvc":{"activated":true,"total_views":1660,"today_views":0},"_links":{"self":[{"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1180","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1180"}],"version-history":[{"count":15,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1180\/revisions"}],"predecessor-version":[{"id":1302,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1180\/revisions\/1302"}],"wp:attachment":[{"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}