The following code works well except I can't think of an elegant way
of checking for the existance of the named field prior to creating
it. Suggestions?
Public Sub pNewField()
'Add a new field to every table in the collection
Dim strSQL As String
Dim db As Database, tdf As TableDef, intI As Integer
Set db = CurrentDb
For intI = 0 To db.TableDefs.Co unt - 1
Set tdf = db.TableDefs(in tI)
' Skip system tables
If Left(tdf.Name, 4) <"MSys" Then
tdf.Fields.Appe nd tdf.CreateField ("Source_tbl ", dbText,
15)
strSQL = "UPDATE [" & tdf.Name & "] SET Source_tbl = " _
& "'" & tdf.Name & "';"
DoCmd.SetWarnin gs False
DoCmd.RunSQL strSQL
DoCmd.SetWarnin gs True
End If
Next
End Sub
Thanks,
Tim Mills-Groninger
of checking for the existance of the named field prior to creating
it. Suggestions?
Public Sub pNewField()
'Add a new field to every table in the collection
Dim strSQL As String
Dim db As Database, tdf As TableDef, intI As Integer
Set db = CurrentDb
For intI = 0 To db.TableDefs.Co unt - 1
Set tdf = db.TableDefs(in tI)
' Skip system tables
If Left(tdf.Name, 4) <"MSys" Then
tdf.Fields.Appe nd tdf.CreateField ("Source_tbl ", dbText,
15)
strSQL = "UPDATE [" & tdf.Name & "] SET Source_tbl = " _
& "'" & tdf.Name & "';"
DoCmd.SetWarnin gs False
DoCmd.RunSQL strSQL
DoCmd.SetWarnin gs True
End If
Next
End Sub
Thanks,
Tim Mills-Groninger
Comment