Function TurnOffSubDataSh()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim prp As DAO.Property
Const conPropName = "SubdatasheetName"
Const conPropValue = "[None]"
Set db = DBEngine(0)(0)
For Each tdf In db.TableDefs
If (tdf.Attributes And dbSystemObject) = 0 Then
If tdf.Connect = vbNullString And Asc(tdf.Name) <> 126 Then 'Not
attached, or temp.
If NoSuchProperty(tdf, conPropName) Then
Set prp = tdf.CreateProperty(conPropName, dbText,
conPropValue)
tdf.Properties.Append prp
Else
If tdf.Properties(conPropName) <> conPropValue Then
tdf.Properties(conPropName) = conPropValue
End If
End If
End If
End If
Next
Set db = Nothing
End Function
Private Function NoSuchProperty(obj As Object, strPropName As String) As
Boolean
Dim varDummy As Variant
On Error Resume Next
varDummy = obj.Properties(strPropName)
NoSuchProperty = (Err.Number = 3270)
On Error GoTo 0
End Function
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Terry said:
What is the correct syntax for creating and appending a new property to a
table? I need to create the property "SubDataSheetName" and give it a value.
Regards