Posted By

qrist0ph on 07/28/08


Tagged

access vba dbadmin


Versions (?)

Schema.ini Datei erzeugen


 / Published in: Visual Basic
 

URL: http://support.microsoft.com/kb/210001

  1. Sub t()
  2. CreateSchemaFile True, "C:\temp\", "EMP.TXT", "Iststd"
  3. End Sub
  4.  
  5. Public Function CreateSchemaFile(bIncFldNames As Boolean, _
  6. sPath As String, _
  7. sSectionName As String, _
  8. sTblQryName As String) As Boolean
  9. Dim Msg As String ' For error handling.
  10. On Local Error GoTo CreateSchemaFile_Err
  11. Dim ws As Workspace, db As DAO.Database
  12. Dim tblDef As DAO.TableDef, fldDef As DAO.Field
  13. Dim i As Integer, Handle As Integer
  14. Dim fldName As String, fldDataInfo As String
  15. ' -----------------------------------------------
  16. ' Set DAO objects.
  17. ' -----------------------------------------------
  18. Set db = CurrentDb()
  19. ' -----------------------------------------------
  20. ' Open schema file for append.
  21. ' -----------------------------------------------
  22. Handle = FreeFile
  23. Open sPath & "schema.ini" For Output Access Write As #Handle
  24. ' -----------------------------------------------
  25. ' Write schema header.
  26. ' -----------------------------------------------
  27. Print #Handle, "[" & sSectionName & "]"
  28. Print #Handle, "ColNameHeader = " & _
  29. IIf(bIncFldNames, "True", "False")
  30. Print #Handle, "CharacterSet = ANSI"
  31. Print #Handle, "Format = TabDelimited"
  32. ' -----------------------------------------------
  33. ' Get data concerning schema file.
  34. ' -----------------------------------------------
  35. Set tblDef = db.TableDefs(sTblQryName)
  36. With tblDef
  37. For i = 0 To .Fields.Count - 1
  38. Set fldDef = .Fields(i)
  39. With fldDef
  40. fldName = .Name
  41. Select Case .Type
  42. Case dbBoolean
  43. fldDataInfo = "Bit"
  44. Case dbByte
  45. fldDataInfo = "Byte"
  46. Case dbInteger
  47. fldDataInfo = "Short"
  48. Case dbLong
  49. fldDataInfo = "Integer"
  50. Case dbCurrency
  51. fldDataInfo = "Currency"
  52. Case dbSingle
  53. fldDataInfo = "Single"
  54. Case dbDouble
  55. fldDataInfo = "Double"
  56. Case dbDate
  57. fldDataInfo = "Date"
  58. Case dbText
  59. fldDataInfo = "Char Width " & Format$(.Size)
  60. Case dbLongBinary
  61. fldDataInfo = "OLE"
  62. Case dbMemo
  63. fldDataInfo = "LongChar"
  64. Case dbGUID
  65. fldDataInfo = "Char Width 16"
  66. End Select
  67. Print #Handle, fldName & "," & fldDataInfo
  68. End With
  69. Next i
  70. End With
  71. MsgBox sPath & "SCHEMA.INI has been created."
  72. CreateSchemaFile = True
  73. CreateSchemaFile_End:
  74. Close Handle
  75. Exit Function
  76. CreateSchemaFile_Err:
  77. Msg = "Error #: " & Format$(Err.Number) & vbCrLf
  78. Msg = Msg & Err.Description
  79. MsgBox Msg
  80. Resume CreateSchemaFile_End
  81. End Function

Report this snippet  

You need to login to post a comment.