cancel
Showing results for 
Search instead for 
Did you mean: 

Form Already Exists

07-25-2012 6:36 AM
622 views 1 comments
0 Likes
Subscribe

Hi

  I have written below code to create Form . I want to put check if form already exists it should not create else it should create.

Private Sub CreateFormWithMatrix()

Try

Dim oItem As SAPbouiCOM.Item

Dim oButton As SAPbouiCOM.Button

Dim oStaticText As SAPbouiCOM.StaticText

Dim oEditText As SAPbouiCOM.EditText

Dim creationPackage

creationPackage = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)

  1. creationPackage.UniqueID = "FrmMatrix1"
  2. creationPackage.FormType = "FrmMatrix1"

oForm = SBO_Application.Forms.AddEx(creationPackage)

  • oForm.Title = "Datasources and Linked Button"
  • oForm.Left = 336
  • oForm.ClientWidth = 520
  • oForm.Top = 44
  • oForm.ClientHeight = 200

Catch oEx As Exception

  1. MessageBox.Show(oEx.Message)

Finally

  1. GC.Collect()

End Try

End Sub

Thanks

0 Likes

Accepted Solutions (0)

Answers (1)

Answers (1)

edy_simon
Active Contributor
0 Likes

Hi,

Try

     'If form already exists, the form will be selected, if not an exception will be thrown

     oForm = sbo_application.forms.item("FrmMatrix1")

Catch

     'Exception has been thrown, the form does not exists, create a new one here.

     'Put your code to create the form here

End Try

Regards
Edy