Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do i dump table definitions into another table?
Message
De
08/01/2002 17:55:09
Jason Dalio
Northern Interior Regional Health Board
Prince George, Colombie Britannique, Canada
 
Information générale
Forum:
Microsoft Office
Catégorie:
Access
Divers
Thread ID:
00602230
Message ID:
00602296
Vues:
17
I wrote you out the floowing piece of code. A few things:

1. I would normally do this in ADO but I wasn't sure if you were familiar with it so it is in DAO (for Access) instead.
2. Make yourself a table called YourDestinationTable with 2 fields: one named FieldName and the other named FieldType both text.
3. I have included a select case from a VBScript table and it is for ADO so the codes probably won't match up. That's OK, you'll just have to experiment and make changes to suit your needs.
4. This is just template. I ix-nayed proper naming conventions and everything else. I'm hoping you know how to code VBA.

Copy the below code into a command button's click event on a form:

Dim db As Database
Dim rst As Recordset
Dim FieldType As String

Dim i As Integer

Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT * FROM CPSImport;")

For i = 0 To rst.Fields.Count - 1
Select Case rst.Fields(0).Type
Case Is = 0
FieldType = "Empty"
Case Is = 2
FieldType = "SmallInt"
Case Is = 3
FieldType = "Integer"
Case Is = 4
FieldType = "Single"
Case Is = 5
FieldType = "Double"
Case Is = 6
FieldType = "Currency"
Case Is = 7
FieldType = "Date"
Case Is = 8
FieldType = "BSTR"
Case Is = 9
FieldType = "Dispatch"
Case Is = 10
FieldType = "Error"
Case Is = 11
FieldType = "Boolean"
Case Is = 12
FieldType = "Variant"
Case Is = 13
FieldType = "Unknown"
Case Is = 14
FieldType = "Decimal"
Case Is = 16
FieldType = "TinyInt"
Case Is = 17
FieldType = "UnsignedTinyInt"
Case Is = 18
FieldType = "UnsignedSmallInt"
Case Is = 19
FieldType = "UnsignedInt"
Case Is = 20
FieldType = "BigInt"
Case Is = 21
FieldType = "UnassignedBigInt"
Case Is = 72
FieldType = "GUID"
Case Is = 128
FieldType = "Binary"
Case Is = 129
FieldType = "Char"
Case Is = 130
FieldType = "WChar"
Case Is = 131
FieldType = "Numeric"
Case Is = 132
FieldType = "UserDefined"
Case Is = 133
FieldType = "DBDate"
Case Is = 134
FieldType = "DBTime"
Case Is = 135
FieldType = "DBTimeStamp"
End Select

db.Execute "INSERT INTO YourDestinationTable (FieldName, FieldType) VALUES ('" & _
rst.Fields(i).Name & "', '" & FieldType & "');"

Next 'i

rst.Close
Set rst = Nothing
db.Close
Set db = Nothing
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform