Book a Demo

Author Topic: Element Feature "Scale" attribute  (Read 3327 times)

Ross

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Element Feature "Scale" attribute
« on: May 05, 2009, 03:04:34 am »
I’m using VBA in MS Access to add attribute data into an .EAP file. (EA version 7.1.833, MS Access 2003 SP3)  When trying to set the Scale attribute of an Element Feature I get a compiler error (Due to the fact that Scale is a reserved word). As per VB syntax, I’ve tried surrounding the Scale word with square brackets ( attr.[Scale] )  in an attempt to escape the reserved word, but then get another error show below (Run-time error ‘438’, Object doesn’t support this property or method). How do I set the Scale attribute without getting an error?



Sub AddCsvAttribute(intElementID As Integer, _
                 strName As String, _
                 strOracleDataType As String, _
                 strPrecision As String, _
                 strScale As String, _
                 strNotes As String)

   Dim attr As Object
   Dim element As Object
   Dim sca As Integer

   Set element = MyRep.GetElementByID(intElementID)
   Set attr = element.Attributes.AddNew(strName, strOracleDataType)
   element.Stereotype = "column"

   If strOracleDataType = "VARCHAR2" Then
      attr.Length = strPrecision
   Else
      attr.Precision = strPrecision
      attr.Scale = strScale
   End If

   attr.Notes = strNotes
   attr.Update
   Debug.Print "Element ID" & element.ElementID
   element.Attributes.Refresh

End Sub

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Element Feature "Scale" attribute
« Reply #1 on: May 05, 2009, 03:29:18 am »
Try calling Update right after you create the new attribute, before you set the scale. Of course you should retain the call to Update after the values are set.
No, you can't have it!

Ross

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Element Feature "Scale" attribute
« Reply #2 on: May 05, 2009, 03:50:12 am »
I added a call to Update after creating the attribute (see code below), but still get an "Object method or property does not exist" error on the call to attr.[Scope].

   Set attr = element.Attributes.AddNew(strName, strOracleDataType)
   attr.Update

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Element Feature "Scale" attribute
« Reply #3 on: May 05, 2009, 06:47:37 am »
I should have looked more closely. I assume you are populating a «table» in a data modeling diagram, in which case you should probably call update after adding the «column» stereotype.

That probably will not solve your problem, but it may help avoid others elsewhere.

I recently created a bunch of data models via VB.Net. It had been some time since I built any from scratch, so I had to relearn some of the tricks. I remember there were quite a few other things I needed to tweak, not all of which were obvious. I did however manage to get all the necessary properties set up via the API. You should open up (a test copy of) a hand-built EA data model project using MS Access to and check all the fields of any table that might be relevant. Make sure you find all the values you have set (I think some of them are set in more than one place). Then work through the API calls and object properties until you can set them all. It takes a while but you only have to do it once.

I just don't have the bandwidth to hunt down my code and parse it out right now. You should be able to solve this before I can get to it. Doing a thorough job now will save you some real headaches down the line when you start playing with your data model or generating code.

David
No, you can't have it!