unable to set AttributeObj.Datatype

sorry, i'm a noob to this. i've written the following attempting to add attributes to a physical model but below when i attempt:

MyAttribute.DefaultName = "timestamp now"

it doesn't work.

i'm tryin g to set the default value from the data dictionary defaults.

the code:

Sub Main

  Dim MyDiagram As Diagram
  Dim MyModel As Model
  Dim MyEntity As Entity
  Dim MyAttribute As AttributeObj

    Set MyDiagram = DiagramManager.ActiveDiagram
    Set MyModel = MyDiagram.ActiveModel

    If Not MyModel.Logical Then
      If MsgBox("This macro will add audit columns to all objects.", vbOkCancel) = vbOK Then
        For Each MyEntity In MyModel.Entities
          Set MyAttribute = MyEntity.Attributes.Add("create_date", False)
          MyAttribute.Datatype = "TIMESTAMP" 
          MyAttribute.Definition = "The datetime the record was created."
          MyAttribute.NullOption = "NOT NULL"
          MyAttribute.DefaultName = "timestamp now" 'not working

      End If
        MsgBox "This macro is designed to run in the Physical model. Please switch to Physical model first."
    End If

End Sub

  • figured it out:

    For Each MyDefaults In MyDiagram.Dictionary.Defaults
      If MyDefaults.Name = "timestamp now" Then
        Set MyTimestampNowDefaultId = MyDefaults.ID


    MyAttribute.DefaultId = MyTimestampNowDefaultId

Reply Children
No Data