Skip to Content
author's profile photo Former Member
Former Member

generate_userfields

i will generate a userfield with values

but the program does not running,

because i get a error - 5002 when i use

ValidValuesMD.

what is wrong on my source code?

best regards

ingo

Public Function generate_userfields()

Dim UFld As SAPbobsCOM.UserFieldsMD

Dim VVFld As SAPbobsCOM.ValidValuesMD

Dim RetVal As Long

Dim ErrCode As Long

Dim ErrMsg As String

Set UFld = vCompany.GetBusinessObject(oUserFields)

UFld.TableName = “OITM”

UFld.Name = "test"

UFld.Description = "test”

UFld.Type = db_Alpha

UFld.Size = 10

RetVal = UFld.Add

The result was 0 in the error routine

Set VVFld = UFld.ValidValues

VVFld.Description = "test"

VVFld.Value = 1

VVFld.Add

The result was –5002 in the error routine

End Function

Add comment
10|10000 characters needed characters exceeded

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 01, 2004 at 02:16 PM

    The description for error -5002 is "Default value is not valid for this field."

    If you are setting a list of valid values, you must specify a default value. Add the following to your code:-

    UFld.DefaultValue = 1

    Regards,

    John.

    Add comment
    10|10000 characters needed characters exceeded