cancel
Showing results for 
Search instead for 
Did you mean: 

Check if form is closed In Business One

former_member551008
Participant
0 Kudos

SAP 8.8

vb.net

How do I check to make sure another form is closed when I am performing actions on a different form?

In this instance I have another form that can not be open while I am using the update button on another form.

How do I check if for is open?

Accepted Solutions (1)

Accepted Solutions (1)

former_member233854
Active Contributor

I usually use this function, you can find out if a specific form is open to prevent the user to open another one

        public static bool IsFormOpen(string typeEx)
        {
            var count = [SAPAPPLICATION].Forms.Cast<IForm>().Count(p => p.TypeEx.Equals(typeEx));

            return count > 0;
        }
former_member551008
Participant
0 Kudos

VB.NET version of this?

former_member233854
Active Contributor
0 Kudos

There are a lot of code converters in the web, besides, it is a small code, you can use this as a base to your vb.net code since the changes are usually smalls.

http://converter.telerik.com/

former_member551008
Participant
0 Kudos

Thank you for all your help in giving me the Idea I needed code converter did not help but I wrote the function as so:

    Public Function IsFormOpen(ByVal typeEx As String) As Boolean


      
        Dim formCounter(SBO_Application.Forms.Count) As Integer


        Dim loopCount As Integer = 1


        Do


            formCounter(loopCount) = loopCount


            If formCounter(loopCount) = SBO_Application.Forms.Count Then
                Exit Do
            End If


            loopCount += 1
        Loop


        loopCount = 1
        Dim formExistence As SAPbouiCOM.Form


        While formCounter(loopCount) < SBO_Application.Forms.Count


            Try
                formExistence = SBO_Application.Forms.GetForm(typeEx, formCounter(loopCount))
                If formExistence.TypeEx = typeEx And formExistence.Visible = True Then

                    Return False
                End If
            Catch ex As Exception
            End Try


            If loopCount <> formCounter.Length Then
                loopCount += 1
            End If
        End While
        Return True
    End Function

former_member233854
Active Contributor

Great that it helped 🙂

Answers (0)