Results 1 to 2 of 2
  1. #1
    saurabhpunn is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    4

    How to use Access Columns Types in .NET

    Hi All,

    I need to know if there is way to figure out if a particular Column in an Access Table is of type "ComboBox" or "TextBox". For Example:

    In Access I'm having a table "XYZ". This has 2 Columns "X" and "Y". In Access, I've assigned the "Display Control" tag (Open any Access Table->Go o to "Design View"-> Go to "Lookup" tab) as "Combobox" for Column "X" and as "TextBox" for Column "Y".

    Is there a way that I can query this property in my C# code? i.e.

    dc = DataTable.Columns[0];
    if (dc.<To Figure Out>.ComboBox)
    {


    //Do Something
    }

    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,616
    Maybe this will help http://msdn.microsoft.com/en-us/libr...ffice.12).aspx
    And this helped me write VBA procedure below to list property info http://www.java2s.com/Code/VBA-Excel...mTableDefs.htm
    Code:
    Sub ListProperties()
        Dim db
        Dim fld As Field 
        Set db = CurrentDb
        For Each fld In db.TableDefs![your table name].Fields
            If fld.Name = "your field name" Then
                Debug.Print "Name: " & fld.Name
                Debug.Print "DisplayControl: " & fld.Properties("DisplayControl").Value
            End If
        Next
        db.Close
    End Sub
    I get these results for Value:
    Textbox - 109
    Listbox - 110
    Combobox - 111

    Some field datatypes don't have DisplayControl property and the code will error if that datatype encountered, Memo and Attachment are two I know of.

    If you want to know C# code, probably need to post in C# forum.
    Last edited by June7; 01-19-2012 at 06:36 PM.
    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.

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

Similar Threads

  1. Field Types
    By ccordner in forum Access
    Replies: 2
    Last Post: 12-13-2011, 12:33 PM
  2. Replies: 1
    Last Post: 11-07-2011, 11:42 AM
  3. Replies: 7
    Last Post: 10-25-2011, 08:32 PM
  4. Memo Data Types
    By Joanne Searcy in forum Database Design
    Replies: 4
    Last Post: 12-28-2010, 08:04 PM
  5. How do I sum entry types in a report?
    By avarusbrightfyre in forum Reports
    Replies: 1
    Last Post: 11-03-2010, 10:11 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