Skip to Content
0
Former Member
Mar 18, 2006 at 01:47 AM

How to add Valid values in user field?

114 Views

Hi,

I'm trying to add a user field (valid values) in my user table, but i don't know what's wrong with my code.

It creates the field, but not the field that i want.

 oUserFieldsMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)

            oUserFieldsMD.TableName = sTableName
            oUserFieldsMD.Name = sFieldName
            oUserFieldsMD.Description = sDescription
            oUserFieldsMD.Type = FieldType
            oUserFieldsMD.Size = iSize

            'Valid Values 1

            oUserFieldsMD.ValidValues.Value = "D"
            oUserFieldsMD.ValidValues.Description = "Disable"
            oUserFieldsMD.ValidValues.Add()
            oUserFieldsMD.DefaultValue = "D"
            'Valid Values 2

            oUserFieldsMD.ValidValues.Value = "A"
            oUserFieldsMD.ValidValues.Description = "Active"
            oUserFieldsMD.ValidValues.Add()
           
            Dim i As Integer
            Dim err As String

            i = oUserFieldsMD.Add()
            If i <> 0 Then
                oCompany.GetLastError(i, err)
                SBO_Application.MessageBox(i & "; " & err)
            End If

😊

Bruce