Author Topic: Problem getting 'Static View' Element in EA 4.0  (Read 3712 times)

khalidlkhan

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Problem getting 'Static View' Element in EA 4.0
« on: June 01, 2004, 04:55:42 am »
I have just migrated to EA 4.0 and find that some VB that I wrote to query EA for model data now no longer works.

Quite simply I would like to get the EAElement for the 'Static View' package. I used the following code:

Set p = EAR.Models.GetByName("Views")
Set e = p.elements.GetByName(“Static View”)

As I said this used to work but I now get the error:

DAO.Database [3075] Syntax error (missing operator) in query expression 'Name='Static View' AND Object_ID in ()'

I had reported this as a bug - but I think it must have fallen on the low priority list or it may be that this was not a bug but that things are done differently in EA 4.0.

I am posting this in case it is the latter.

(I am working with the assumption that if this was a bug then EA 4.0 would have stopped alot of VBA integrated stuff out there and this would have been seen as slightly higher priority.)

Any help greatly appreciated.

Khalid


charge

  • EA User
  • **
  • Posts: 22
  • Karma: +0/-0
    • View Profile
Re: Problem getting 'Static View' Element in EA 4.
« Reply #1 on: June 10, 2004, 02:58:04 am »
I have my own function to find a package by name:

   Private Sub btnExport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExport.Click
       Dim eaoEA As EA.Repository
       Dim eaAppEA As EA.App

       'open EA
       eaAppEA = CreateObject("EA.App")
       eaoEA = eaAppEA.Repository
       eaoEA.OpenFile(Me.txtPath.Text)


       'do somthing
       Dim objPackage As EA.Package
       Try
           objPackage = FindPackage(Nothing, "Data Model", eaoEA)
           
       Dim obj As EA.Element
       obj = objPackage.Elements.AddNew("test", "table")
       obj.Update()


       Catch ex As Exception
           MessageBox.Show(ex.ToString)
       End Try

       
       'close EA
       eaoEA.Exit()
       eaoEA = Nothing
   End Sub


  Private Function FindPackage(ByVal StartPackage As EA.Package, ByVal PackageName As String, Optional ByVal eaoEA As EA.Repository = Nothing) As EA.Package
       Dim objPackage As EA.Package
       Dim objReturnPackage As EA.Package
       If StartPackage Is Nothing Then

           Dim idx As Integer
           For idx = 0 To eaoEA.Models.Count - 1
               objPackage = eaoEA.Models.GetAt(idx)
               objReturnPackage = FindPackage(objPackage, PackageName)
               If Not objReturnPackage Is Nothing Then
                   Return objReturnPackage
               End If
           Next
       Else
           If StartPackage.Name.ToLower = PackageName.ToLower Then
               Return StartPackage
           Else
               For Each objPackage In StartPackage.Packages
                   objReturnPackage = FindPackage(objPackage, PackageName)
                   If Not objReturnPackage Is Nothing Then
                       Return objReturnPackage
                   End If

               Next
           End If
       End If

   End Function