I'm testing using the following to print field names and data types of the Access tables in my db.
It works fine for Access tables, local and linked.
I'm curious if it's possible to do something similar with the DB2 tables we connect to, via ODBC?
There are a lot of them and some have a large number of fields.
The above code in red doesn't work but, if I could find something along the same lines, I'd use an 'If' statement, based on the name of the remote db being in the connection string.
Edit:
Every time I save, it strips off the colour. The lines that should be in red are
strFieldName = CurrentDb.TableDefs(Tdf.Name).Fields(intCounter).Name
intFieldType = CurrentDb.TableDefs(Tdf.Name).Fields(intCounter).Type
Code:
For Each Tdf In RemoteDb.TableDefs
intNumberofFields = Tdf.Fields.Count
For intCounter = 0 To intNumberofFields - 1
strFieldName = CurrentDb.TableDefs(Tdf.Name).Fields(intCounter).Name
intFieldType = CurrentDb.TableDefs(Tdf.Name).Fields(intCounter).Type
Select Case intFieldType
Case 2 'Byte
strTypeName = "Byte"
Case 3 'Integer
strTypeName = "Integer"
Case 4 'Long
strTypeName = "Long"
Case 6 'Single
strTypeName = "Single"
Case 7 'Double
strTypeName = "Double"
Case Else 'Not a Number
strTypeName = "N/A"
End Select
debug.print tdf.name & " - " & strFieldName & " - " & strTypeName
Next intcounter
I'm curious if it's possible to do something similar with the DB2 tables we connect to, via ODBC?
There are a lot of them and some have a large number of fields.
The above code in red doesn't work but, if I could find something along the same lines, I'd use an 'If' statement, based on the name of the remote db being in the connection string.
Edit:
Every time I save, it strips off the colour. The lines that should be in red are
strFieldName = CurrentDb.TableDefs(Tdf.Name).Fields(intCounter).Name
intFieldType = CurrentDb.TableDefs(Tdf.Name).Fields(intCounter).Type
Last edited: