Solved

ERWIN and Access

Posted on 1998-12-17
7
951 Views
Last Modified: 2013-12-25
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.

Regards
Paulo
0
Comment
Question by:sergio_2001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 
LVL 15

Accepted Solution

by:
ameba earned 50 total points
ID: 1498360
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
0
 

Author Comment

by:sergio_2001
ID: 1498361
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:")
***
0
 
LVL 15

Expert Comment

by:ameba
ID: 1498362
' 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

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

0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 15

Expert Comment

by:ameba
ID: 1498363
Usage:
Call SetFieldProp (ERwinField, "Caption", DB_TEXT, "Desc. Cor:")
or
SetFieldProp ERwinField, "Caption", DB_TEXT, "Desc. Cor:"
' note this is without parens()

0
 
LVL 15

Expert Comment

by:ameba
ID: 1498364
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(šðÈÆŽ)
0
 
LVL 15

Expert Comment

by:ameba
ID: 1498365
Small correction:
Replace last argument
   ..., pValue As String)
with
   ..., pValue As Variant)

so it will accept other property types, not only strings
0
 

Author Comment

by:sergio_2001
ID: 1498366
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.

Regards
Paulo
0

Featured Post

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month7 days, 21 hours left to enroll

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question