How to convert to

Posted on 2001-06-25
Last Modified: 2012-06-21

I need to create mdb files on the fly with data from SQL server. I'll be getting data through When I try to create mdb file using the following syntex:

Set dbDatabase = CreateDatabase(sNewDBPathAndName, dbLangGeneral, dbEncrypt)

For Each fld In rs.Fields
    Set fldArray(i) = tdLogTable.CreateField(fld.Name, fld.Type, fld.DefinedSize)
    i = i + 1

the program error out at the table.CreateField method. The "fld.Type" returns an type which can't be recognized by the CreateField method. Can anyone show me how to solve this? Thanks in advance!
Question by:ahpui

Accepted Solution

rkot2000 earned 50 total points
ID: 6224775
i am using the following select case to convert from ado to string. You can do the same :
Function GetDataTypeEnum(lngDataTypeEnum As Long) As String
      'Given ADO data-type constant, returns readable constant name.
      Dim strReturn As String
         Select Case lngDataTypeEnum
            Case 0: strReturn = "adEmpty"
            Case 16: strReturn = "adTinyInt"
            Case 2: strReturn = "adSmallInt"
            Case 3: strReturn = "adInteger"
            Case 20: strReturn = "adBigInt"
            Case 17: strReturn = "adUnsignedTinyInt"
            Case 18: strReturn = "adUnsignedSmallInt"
            Case 19: strReturn = "adUnsignedInt"
            Case 21: strReturn = "adUnsignedBigInt"
            Case 4: strReturn = "adSingle"
            Case 5: strReturn = "adDouble"
            Case 6: strReturn = "adCurrency"
            Case 14: strReturn = "adDecimal"
            Case 131: strReturn = "adNumeric"
            Case 11: strReturn = "adBoolean"
            Case 10: strReturn = "adError"
            Case 132: strReturn = "adUserDefined"
            Case 12: strReturn = "adVariant"
            Case 9: strReturn = "adIDispatch"
            Case 13: strReturn = "adIUnknown"
            Case 72: strReturn = "adGUID"
            Case 7: strReturn = "adDate"
            Case 133: strReturn = "adDBDate"
            Case 134: strReturn = "adDBTime"
            Case 135: strReturn = "adDBTimeStamp"
            Case 8: strReturn = "adBSTR"
            Case 129: strReturn = "adChar"
            Case 200: strReturn = "adVarChar"
            Case 201: strReturn = "adLongVarChar"
            Case 130: strReturn = "adWChar"
            Case 202: strReturn = "adVarWChar"
            Case 203: strReturn = "adLongVarWChar"
            Case 128: strReturn = "adBinary"
            Case 204: strReturn = "adVarBinary"
            Case 205: strReturn = "adLongVarBinary"
         Case Else:
            strReturn = "Unknown"
          End Select
         GetDataTypeEnum = strReturn
      End Function

Author Comment

ID: 6229356
Thanks! It works after a minor modification.

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Saving history changes to sub form 4 26
Hide vba in gp 7 49
Add and format columns in vb6 7 26
Added a column screws up code 5 17
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now