ERWIN and Access

Hi all,

I have one script genereted by Erwin. But there are one "command" **SetFieldProp** that VB5 don't know.
Does someone know the equivalent command in VB5? Or another one solution to run this script to generate one Access DB?
I hope to be clear.

Who is Participating?

Improve company productivity with a Business Account.Sign Up

amebaConnect With a Mentor Commented:
I am not using Erwin at a moment, not sure how your script looks like, but:
In VB5 you can add properties to the field definition:

E.g. If you have to set a property:
VALMSG "This ID does not exist!"

' you should do this
With gtdfTableDef.Fields(fldName)
   .Properties.Append .CreateProperty("VALMSG", dbText, "This ID does not exist!")
End With

You cannot do this in the moment of field creation, but after it exists.
So, you cannot:
  'get a fresh field object
  Set fld = gtdfTableDef.CreateField()
  'fill the field structure
  With fld
    .Name = ...
    .Size = ...
    .Properties.Append ... ' error invalid operation
  End With
Instead, you must do it in the second 'pass'.

To set existing property, use:
 gtdfTableDef.Fields(fldName).Properties("VALMSG").Value = "This ID does not exist!"

See also:
CreateProperty, Properties Collection, in VB Help
sergio_2001Author Commented:
Hi ameba,

I'm sending one part of the code. Since I'm not one VB programmer it's not too easy analize your answer. I'm using VB just to generate the database.

'  CREATE TABLE "cores"
Set ERwinTableDef = ERwinDatabase.CreateTableDef("cores")
Set ERwinField = ERwinTableDef.CreateField("cd_cor", DB_INTEGER)
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("ds_cor_abrev", DB_TEXT, 15)
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("ds_cor", DB_TEXT, 36)
ERwinTableDef.Fields.Append ERwinField
ERwinDatabase.TableDefs.Append ERwinTableDef
Set ERwinField = ERwinTableDef.Fields("cd_cor")
SetFieldProp (ERwinField, "Caption", DB_TEXT, "Cód Cor:")
Set ERwinField = ERwinTableDef.Fields("ds_cor_abrev")
SetFieldProp (ERwinField, "Caption", DB_TEXT, "Desc. Cor Abreviado:")
Set ERwinField = ERwinTableDef.Fields("ds_cor")
SetFieldProp (ERwinField, "Caption", DB_TEXT, "Desc. Cor:")
' add this sub to your module
Sub SetFieldProp(fld As Field, pName As String, pType As Integer, pValue As String)
    On Error GoTo propError
    ' append property
    With fld
        .Properties.Append .CreateProperty(pName, pType, pValue)
    End With
    Exit Sub

    ' probably error is: 3367, Can't append.  An object with that name already exists
    On Error GoTo othererr
    ' perhaps property exists, so just set value
    fld.Properties(pName).Value = pValue
    Exit Sub
    Debug.Print "Err: " & Err.Number & ", " & Err.Description
    Exit Sub
End Sub

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Call SetFieldProp (ERwinField, "Caption", DB_TEXT, "Desc. Cor:")
SetFieldProp ERwinField, "Caption", DB_TEXT, "Desc. Cor:"
' note this is without parens()

You will perhaps have some more errors. I remember it was a lot of trials converting to .Mdb
Be sure to remove all locale characters from script(šðÈÆŽ)
Small correction:
Replace last argument
   ..., pValue As String)
   ..., pValue As Variant)

so it will accept other property types, not only strings
sergio_2001Author Commented:
Hi ameba,

The code was compiled folowing your tip without errors. But I didn't saw the result yet within Access. I suppose will be all right.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.