Solved

How to return the field type and field size of a table

Posted on 2014-10-20
6
255 Views
Last Modified: 2014-10-20
I am trying to determine the data type and size of fields in a specified table.
I am using the following code to return the list of fields in the table and write the information to table "TableFieldNames"

        Dim fld As DAO.Field
        Dim db As DAO.Database
        Dim rs2 As DAO.Recordset

        Set db = OpenDatabase(txtdatabasename)    
        Set rs2 = Currentdb.OpenRecordset("TableFieldNames")
        Currentdb.Execute ("DELETE TableFieldNames.* FROM TableFieldNames")

        For Each fld In db.TableDefs(cmbTable).Fields
              rs2.AddNew
              rs2!NamofTable = cmbTable
              rs2!NameOfField = fld.Name
              rs2!TypeofField = ??????????
              rs2!SizeofField = ?????????
              rs2.Update
        Next fld
        rs2.close

In rs2!TypeofField I want to put the specified data type for the field (Text, Number, Date/Time, etc.)
If the data type is Text or Number I want to put the specified field size in rs2!Sizeoffield (255, integer, double, etc.)
Is this doable?
0
Comment
Question by:dsoderstrom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40392510
use

              rs2!TypeofField = fld.type
              rs2!SizeofField = fld.size
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 40392521
see this link to get the field description and other attributes

http://allenbrowne.com/func-06.html
0
 

Author Comment

by:dsoderstrom
ID: 40392538
I tried using fld.type and fld.size but what I get is numbers.
For example, a field that has a data type of "Text" returns a "10" for the field type.  The field size returns correctly.
A field with a data type of "Number" and a field size of "Double" returns "7" for the datatype and "8" for the field size.
Is there a way to return the actual data type and size as it shows in the field properties of the table?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40392548
look at my second post..
0
 

Author Comment

by:dsoderstrom
ID: 40392554
Yep, sorry.  Responded to your first one before I got the second one.
Just trying it now.
0
 

Author Closing Comment

by:dsoderstrom
ID: 40392570
this was just what I needed.
Thanks once again.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

634 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question