Does anyone know how to return a property value and then convert the number the function returns to the constant that the number represents?
As in:
The values returned by lines 1 and 2 above are numbers, like 4, 7 , 8, etc. How do you convert those numbers to "vbLong", "vbdate", etc?
Thanks for your help.
Michael.Kemp@gs.com
As in:
Code:
Sub GetFieldProperties()
Dim dbs As Database, rst As Recordset, fld_1 As Field, fld_2 As Field, sql_1 As String, sql_2 As String, a_tbln, _
x As Integer, tdf As TableDef, fld As Field
Set dbs = CurrentDb
Set tdf = dbs.TableDefs("tblNew_Tables")
Set fld_1 = tdf.CreateField("FieldType", dbText)
Set fld_2 = tdf.CreateField("FieldSize", dbText)
tdf.Fields.Append fld_1
tdf.Fields.Append fld_2
tdf.Fields.Refresh
a_tbln = Array("tbl_12_2000_GS_Main_idBox", "tbl_12_2000_PIFS_idBox", "tbl_2000_GRMT_Original_idBox")
For x = 1 To 3
For Each fld In dbs.TableDefs(a_tbln(x)).Fields
sql_1 = "select tblNew_Tables.* from tblNew_Tables where " _
& "tblNew_Tables.TableName='" & a_tbln(x) & "' and tblNew_Tables.FieldName='" & fld.Name & "';"
Set rst = dbs.OpenRecordset(sql_1)
If rst.RecordCount > 0 Then
rst.Edit
1 rst.Fields("FieldType").Value = fld.Type
2 rst.Fields("FieldSize").Value = fld.Size
rst.Update
End If
Next fld
Next x
Set rst = Nothing
End Sub
Thanks for your help.
Michael.Kemp@gs.com