sergio_2001
asked on
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.
Regards
Paulo
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
' 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).Valu e = pValue
Exit Sub
othererr:
Debug.Print "Err: " & Err.Number & ", " & Err.Description
Exit Sub
End Sub
'
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).Valu
Exit Sub
othererr:
Debug.Print "Err: " & Err.Number & ", " & Err.Description
Exit Sub
End Sub
Usage:
Call SetFieldProp (ERwinField, "Caption", DB_TEXT, "Desc. Cor:")
or
SetFieldProp ERwinField, "Caption", DB_TEXT, "Desc. Cor:"
' note this is without parens()
Call SetFieldProp (ERwinField, "Caption", DB_TEXT, "Desc. Cor:")
or
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(šðÈÆŽ)
Be sure to remove all locale characters from script(šðÈÆŽ)
Small correction:
Replace last argument
..., pValue As String)
with
..., pValue As Variant)
so it will accept other property types, not only strings
Replace last argument
..., pValue As String)
with
..., pValue As Variant)
so it will accept other property types, not only strings
ASKER
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
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
ASKER
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.CreateTableD
Set ERwinField = ERwinTableDef.CreateField(
ERwinField.Required = True
ERwinTableDef.Fields.Appen
Set ERwinField = ERwinTableDef.CreateField(
ERwinTableDef.Fields.Appen
Set ERwinField = ERwinTableDef.CreateField(
ERwinTableDef.Fields.Appen
ERwinDatabase.TableDefs.Ap
Set ERwinField = ERwinTableDef.Fields("cd_c
SetFieldProp (ERwinField, "Caption", DB_TEXT, "Cód Cor:")
Set ERwinField = ERwinTableDef.Fields("ds_c
SetFieldProp (ERwinField, "Caption", DB_TEXT, "Desc. Cor Abreviado:")
Set ERwinField = ERwinTableDef.Fields("ds_c
SetFieldProp (ERwinField, "Caption", DB_TEXT, "Desc. Cor:")
***