VERSION 5.00
Begin VB.Form SeekForm 
   BorderStyle     =   1  'Fixed Single
   Caption         =   " "
   ClientHeight    =   7950
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   12720
   ControlBox      =   0   'False
   LinkTopic       =   "SeekForm"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   7950
   ScaleWidth      =   12720
   StartUpPosition =   2  'CenterScreen
   Begin VB.Frame fra_like 
      Caption         =   "#like"
      Height          =   1035
      Left            =   60
      TabIndex        =   18
      Tag             =   "fra_like"
      Top             =   1500
      Width           =   4095
      Begin VB.TextBox txt_like 
         Height          =   315
         Left            =   120
         TabIndex        =   22
         Top             =   240
         Width           =   3850
      End
      Begin VB.OptionButton opt_like 
         Caption         =   "#Begin by"
         Height          =   255
         Index           =   0
         Left            =   120
         TabIndex        =   21
         Tag             =   "like0"
         Top             =   660
         Value           =   -1  'True
         Width           =   1250
      End
      Begin VB.OptionButton opt_like 
         Caption         =   "#Contains"
         Height          =   255
         Index           =   1
         Left            =   1380
         TabIndex        =   20
         Tag             =   "like1"
         Top             =   660
         Width           =   1250
      End
      Begin VB.OptionButton opt_like 
         Caption         =   "#Ended by"
         Height          =   255
         Index           =   2
         Left            =   2640
         TabIndex        =   19
         Tag             =   "like2"
         Top             =   660
         Width           =   1250
      End
   End
   Begin VB.Frame fra_equal 
      Caption         =   "#equal"
      Height          =   1035
      Left            =   60
      TabIndex        =   23
      Tag             =   "fra_equal"
      Top             =   1500
      Width           =   4095
      Begin Project1.ArmCombobox cbo_equal 
         Height          =   345
         Left            =   120
         TabIndex        =   27
         Top             =   360
         Width           =   3850
         _ExtentX        =   6800
         _ExtentY        =   609
      End
   End
   Begin VB.TextBox txt_TvFilters 
      Appearance      =   0  'Flat
      BackColor       =   &H0000FFFF&
      BorderStyle     =   0  'None
      Enabled         =   0   'False
      Height          =   315
      Left            =   4260
      MultiLine       =   -1  'True
      TabIndex        =   28
      Top             =   780
      Width           =   8415
   End
   Begin Project1.ArmGrid grd_search 
      Height          =   6315
      Left            =   4260
      TabIndex        =   25
      Top             =   1620
      Width           =   8415
      _ExtentX        =   14843
      _ExtentY        =   11139
   End
   Begin VB.TextBox txt_GridFilter 
      Appearance      =   0  'Flat
      BackColor       =   &H0000FFFF&
      BorderStyle     =   0  'None
      Enabled         =   0   'False
      Height          =   495
      Left            =   4260
      MultiLine       =   -1  'True
      TabIndex        =   24
      Top             =   1080
      Width           =   8415
   End
   Begin VB.Frame fra_country 
      Caption         =   "#country"
      Height          =   675
      Left            =   60
      TabIndex        =   1
      Tag             =   "fra_country"
      Top             =   780
      Width           =   4095
      Begin Project1.ArmCombobox cbo_country 
         Height          =   345
         Left            =   120
         TabIndex        =   26
         Top             =   240
         Width           =   3850
         _ExtentX        =   6800
         _ExtentY        =   609
      End
   End
   Begin Project1.ToolBr tb_top 
      Align           =   1  'Align Top
      Height          =   690
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   12720
      _ExtentX        =   22437
      _ExtentY        =   1217
   End
   Begin VB.Frame fra_criteria 
      Caption         =   "#criteria"
      Height          =   5295
      Left            =   60
      TabIndex        =   2
      Tag             =   "fra_criteria"
      Top             =   2640
      Width           =   4095
      Begin VB.OptionButton opt_criteria 
         Caption         =   "#criteria15"
         Height          =   315
         Index           =   15
         Left            =   480
         TabIndex        =   29
         Tag             =   "crit15"
         Top             =   4800
         Width           =   2595
      End
      Begin VB.OptionButton opt_criteria 
         Caption         =   "#criteria0"
         Height          =   315
         Index           =   0
         Left            =   480
         TabIndex        =   17
         Tag             =   "crit0"
         Top             =   300
         Value           =   -1  'True
         Width           =   2595
      End
      Begin VB.OptionButton opt_criteria 
         Caption         =   "#criteria6"
         Height          =   315
         Index           =   6
         Left            =   480
         TabIndex        =   16
         Tag             =   "crit6"
         Top             =   2100
         Width           =   2595
      End
      Begin VB.OptionButton opt_criteria 
         Caption         =   "#criteria5"
         Height          =   315
         Index           =   5
         Left            =   480
         TabIndex        =   15
         Tag             =   "crit5"
         Top             =   1800
         Width           =   2595
      End
      Begin VB.OptionButton opt_criteria 
         Caption         =   "#criteria4"
         Height          =   315
         Index           =   4
         Left            =   480
         TabIndex        =   14
         Tag             =   "crit4"
         Top             =   1500
         Width           =   2595
      End
      Begin VB.OptionButton opt_criteria 
         Caption         =   "#criteria3"
         Height          =   315
         Index           =   3
         Left            =   480
         TabIndex        =   13
         Tag             =   "crit3"
         Top             =   1200
         Width           =   2595
      End
      Begin VB.OptionButton opt_criteria 
         Caption         =   "#criteria2"
         Height          =   315
         Index           =   2
         Left            =   480
         TabIndex        =   12
         Tag             =   "crit2"
         Top             =   900
         Width           =   2595
      End
      Begin VB.OptionButton opt_criteria 
         Caption         =   "#criteria1"
         Height          =   315
         Index           =   1
         Left            =   480
         TabIndex        =   11
         Tag             =   "crit1"
         Top             =   600
         Width           =   2595
      End
      Begin VB.OptionButton opt_criteria 
         Caption         =   "#criteria7"
         Height          =   315
         Index           =   7
         Left            =   480
         TabIndex        =   10
         Tag             =   "crit7"
         Top             =   2400
         Width           =   2595
      End
      Begin VB.OptionButton opt_criteria 
         Caption         =   "#criteria8"
         Height          =   315
         Index           =   8
         Left            =   480
         TabIndex        =   9
         Tag             =   "crit8"
         Top             =   2700
         Width           =   2595
      End
      Begin VB.OptionButton opt_criteria 
         Caption         =   "#criteria9"
         Height          =   315
         Index           =   9
         Left            =   480
         TabIndex        =   8
         Tag             =   "crit9"
         Top             =   3000
         Width           =   2595
      End
      Begin VB.OptionButton opt_criteria 
         Caption         =   "#criteria10"
         Height          =   315
         Index           =   10
         Left            =   480
         TabIndex        =   7
         Tag             =   "crit10"
         Top             =   3300
         Width           =   2595
      End
      Begin VB.OptionButton opt_criteria 
         Caption         =   "#criteria11"
         Height          =   315
         Index           =   11
         Left            =   480
         TabIndex        =   6
         Tag             =   "crit11"
         Top             =   3600
         Width           =   2595
      End
      Begin VB.OptionButton opt_criteria 
         Caption         =   "#criteria12"
         Height          =   315
         Index           =   12
         Left            =   480
         TabIndex        =   5
         Tag             =   "crit12"
         Top             =   3900
         Width           =   2595
      End
      Begin VB.OptionButton opt_criteria 
         Caption         =   "#criteria13"
         Height          =   315
         Index           =   13
         Left            =   480
         TabIndex        =   4
         Tag             =   "crit13"
         Top             =   4200
         Width           =   2595
      End
      Begin VB.OptionButton opt_criteria 
         Caption         =   "#criteria14"
         Height          =   315
         Index           =   14
         Left            =   480
         TabIndex        =   3
         Tag             =   "crit14"
         Top             =   4500
         Width           =   2595
      End
   End
End
Attribute VB_Name = "SeekForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'what is new
'4.0.1 Default Country settings (JN)



Private Const SEP As String = "ой"
'******** INTERFACE
Private ms_ComponentType As String
Private m_Language As String
Private ms_SelectedItemCode As String
Private ms_SelectedItemDesc As String
Private mSelectedItemFull As String
Private ms_TreeViewFilters As String
Private ms_TreeViewFiltersDesc As String
Private ms_TreeView_DateType As String
Private ms_viewType  As String              ' task298.8
Private md_folowUpMaxDate As Date           ' task298.8
Private ms_defaultCountry As String         ' 23.10.2013 (JN)


'******** Connection Cursor
Private mo_ArmDb As Object
Private mb_Created As Boolean
Private mb_use_framework_connection As Boolean
Private ms_ConnectString As String
Private ms_UID As String

'******** Stored Procedures
Private ms_ScreenName As String
Private ms_searchProcStoc As String
Private ms_cboCriteriaProcStoc() As String
Private ms_cboCriteriaSearchPrefix() As String

'********
Private mi_nbOfCriteria As Integer
Private mi_DescColIndex As Integer
Private mb_UseOfLike As Boolean

'******** Search Criterias
Private ms_filter() As String
'store all the search criterias, even recursive

Private p_DefaultValues(MAX_VALUE) As DefaultValue
Private p_DefaultValuesCount As Integer

Private ms_GridFilter As String

Private mb_SelectedData As Boolean
Private mtxtLike As Boolean

Private ms_CGCode As String
Private ml_SysCode As Long

Public Property Get SelectedData() As Boolean
    SelectedData = mb_SelectedData
End Property

Public Property Set ArmDb(ByRef ao_local_connection As Object)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:ArmDb_Set"
    #End If
    CapMouseOff
    If Not (ao_local_connection Is Nothing) Then
        Set mo_ArmDb = ao_local_connection
        mb_use_framework_connection = True
        Set grd_search.ArmDb = mo_ArmDb
        Set cbo_country.ArmDb = mo_ArmDb
        Set cbo_equal.ArmDb = mo_ArmDb
        Set tb_top.ArmDb = mo_ArmDb
    End If
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:ArmDb_Set"
    #End If
    CapMouseOn
End Property

Public Property Let ConnectString(as_ConnectString As String)
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:ConnectString_Set", "as_ConnectString=" & as_ConnectString
    #End If
    CapMouseOff
    ms_UID = ConnectionStringValidation(as_ConnectString)
    If ms_UID = "" Then GoTo Trace_End
    
    ms_ConnectString = as_ConnectString
    
    grd_search.ConnectString = ms_ConnectString
    cbo_country.ConnectString = ms_ConnectString
    cbo_equal.ConnectString = ms_ConnectString
    tb_top.ConnectString = ms_ConnectString

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:ConnectString_Set"
    #End If
    CapMouseOn
End Property

Public Property Let Language(as_Language As String)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:Language_Let", "as_Language=" & as_Language
    #End If
    CapMouseOff
    m_Language = as_Language
    tb_top.Language = m_Language
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:Language_Let"
    #End If
    CapMouseOn
End Property

Public Property Get SYS_code() As Long
  
    #If CompDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_Seek:SYS_code"
    #End If
  
    SYS_code = ml_SysCode

    #If CompDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_Seek:SYS_code", "Result=" & SYS_code
    #End If
    
End Property

Public Property Let SYS_code(al_SysCode As Long)
  
    #If CompDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_Seek:SYS_code_Let", "ai_Value=" & ai_Value
    #End If
  
    ml_SysCode = al_SysCode
    
    If ml_SysCode = 1 Then
        InitBusinessObjectWhenSAP
    Else
        InitBusinessObject
    End If

    #If CompDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_Seek:SYS_code_Let"
    #End If
    
End Property

Public Sub DisplayDefaultValues()
Dim i As Integer
Dim TheControl As Control
Dim TheControlName As String

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:DisplayDefaultValues"
    #End If

    For i = 0 To p_DefaultValuesCount - 1
        TheControlName = p_DefaultValues(i).FieldName
        Set TheControl = Me.Controls(TheControlName)
        Select Case TypeName(TheControl)
            Case "ArmComboBox"
                If Trim$(p_DefaultValues(i).CodeValue) <> "" Then
                    TheControl.AddItem Array(p_DefaultValues(i).CodeValue, p_DefaultValues(i).DescValue)
                End If
            Case "TextBox"
                TheControl.Text = p_DefaultValues(i).DescValue
        End Select
    Next i

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:DisplayDefaultValues"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SeekForm:DisplayDefaultValues"
    CapMouseOn
End Sub

Private Sub SetDefaultValues(AScreenName As String)
Dim i As Integer

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:SetDefaultValues", "AScreenName=" & AScreenName
    #End If

    'Not reload each time
    If p_DefaultValuesCount > 0 Then GoTo Trace_End

    If Not ASC_ConnectToDB(mo_ArmDb, ms_ConnectString, mb_Created) Then GoTo Trace_End

    p_DefaultValuesCount = GetScreenDefaultValues(mo_ArmDb, ms_UID, m_Language, AScreenName, p_DefaultValues)

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:SetDefaultValues"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SeekForm:SetDefaultValues"
    CapMouseOn
End Sub


Public Property Let ComponentType(as_componentType As String)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:ComponentType_Let", "as_componentType=" & as_componentType
    #End If
    
    ms_ComponentType = as_componentType
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:ComponentType_Let"
    #End If
End Property

Public Property Get SelectedItemCode() As String
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:SelectedItemCode_Get"
    #End If
    
    SelectedItemCode = ms_SelectedItemCode
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:SelectedItemCode_Get", "Result=" & SelectedItemCode
    #End If
End Property

Public Property Get SelectedItemDesc() As String
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:SelectedItemDesc_Get"
    #End If
    
    SelectedItemDesc = ms_SelectedItemDesc
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:SelectedItemDesc_Get", "Result=" & SelectedItemDesc
    #End If
End Property

Public Property Get SelectedItemFull() As String
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:SelectedItemFull_Get"
    #End If
    
    SelectedItemFull = mSelectedItemFull
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:SelectedItemFull_Get", "Result=" & mSelectedItemFull
    #End If
End Property



Public Sub Load_A_COM()
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:Load_A_Com"
    #End If
    
'P516
    ml_SysCode = 11
    
    VerifyInitialization mo_ArmDb, ms_ConnectString, m_Language, Me

    cbo_country.Load_A_COM
    cbo_equal.Load_A_COM
    grd_search.Load_A_COM
    tb_top.Load_A_COM
    
    RefreshFilters
    InitControls

    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:Load_A_Com"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SeekForm:Load_A_Com"
    CapMouseOn
End Sub

Private Sub ValidSelection()
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:ValidSelection"
    #End If

    If grd_search.Rows = 0 Then GoTo Trace_End

    If grd_search.Row < 0 Then
        Call ASC_SendMessage(mo_ArmDb, m_Language, 921, "#Please, select a line")
        GoTo Trace_End
    End If

    ms_SelectedItemCode = grd_search.CurrentKey(0)
    If ms_ComponentType = "PRODUCT" Then
        ms_SelectedItemCode = ms_SelectedItemCode & CH_LDELIMIT & grd_search.CurrentKey(1)
    End If
        
    ms_SelectedItemDesc = grd_search.CurrentLine(mi_DescColIndex)
    
    If ms_SelectedItemCode = "" Then
        Call ASC_SendMessage(mo_ArmDb, m_Language, 921, "#Please, select a line")
        GoTo Trace_End
    End If

    
    Dim lIdx As Long, lCount As Long
    Dim lBuffer As Variant
    lCount = grd_search.Cols - 1
    ReDim lBuffer(lCount)
    For lIdx = 0 To lCount
        lBuffer(lIdx) = grd_search.Columns(lIdx).Name & SEP & grd_search.CurrentLine(grd_search.Columns(lIdx).Name)
    Next
    mSelectedItemFull = Join(lBuffer, SEP & SEP)
        
    mb_SelectedData = True
    
    Me.Hide
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:ValidSelection"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SeekForm:ValidSelection"
    CapMouseOn
End Sub

Private Sub cbo_equal_ComboItemSelected()
Dim i As Integer
Dim ll_BeginParam As Long
Dim ll_EndParam As Long

    If ms_ComponentType = "PRODUCT" And opt_criteria(0).Value = True Then
        If Not cbo_equal.SelectedItem Is Nothing Then
            If cbo_equal.SelectedItem.Key = "" Then
                ms_CGCode = ""
                For i = 1 To 9
                    opt_criteria(i).Enabled = False
                    ms_filter(i) = ""
                    ll_BeginParam = InStr(1, ms_GridFilter, opt_criteria(i).Caption, vbTextCompare)
                    If ll_BeginParam <> 0 Then
                        ll_BeginParam = ll_BeginParam + Len(opt_criteria(i).Caption)
                        ll_EndParam = InStr(ll_BeginParam, ms_GridFilter, ")", vbTextCompare)
                        ms_GridFilter = Mid(ms_GridFilter, 1, ll_BeginParam) & " = """"" & Mid(ms_GridFilter, ll_EndParam, Len(ms_GridFilter) - ll_EndParam + 1)
                    End If
                Next
                FindData True
            Else
                If ms_CGCode <> cbo_equal.SelectedItem.Key Then
                    ms_CGCode = cbo_equal.SelectedItem.Key
                    For i = 1 To 9
                        opt_criteria(i).Enabled = True
                        ms_filter(i) = ""
                        ll_BeginParam = InStr(1, ms_GridFilter, opt_criteria(i).Caption, vbTextCompare)
                        If ll_BeginParam <> 0 Then
                            ll_BeginParam = ll_BeginParam + Len(opt_criteria(i).Caption)
                            ll_EndParam = InStr(ll_BeginParam, ms_GridFilter, ")", vbTextCompare)
                            ms_GridFilter = Mid(ms_GridFilter, 1, ll_BeginParam) & " = """"" & Mid(ms_GridFilter, ll_EndParam, Len(ms_GridFilter) - ll_EndParam + 1)
                        End If
                    Next
                    FindData True
                End If
            End If
        Else
            ms_CGCode = ""
            For i = 1 To 9
                opt_criteria(i).Enabled = False
                ms_filter(i) = ""
                ll_BeginParam = InStr(1, ms_GridFilter, opt_criteria(i).Caption, vbTextCompare)
                If ll_BeginParam <> 0 Then
                    ll_BeginParam = ll_BeginParam + Len(opt_criteria(i).Caption)
                    ll_EndParam = InStr(ll_BeginParam, ms_GridFilter, ")", vbTextCompare)
                    ms_GridFilter = Mid(ms_GridFilter, 1, ll_BeginParam) & " = """"" & Mid(ms_GridFilter, ll_EndParam, Len(ms_GridFilter) - ll_EndParam + 1)
                End If
            Next
            FindData True
        End If
    End If
    
End Sub

Private Sub Form_Activate()
    opt_criteria_Click 0
End Sub

Private Sub Form_Load()
    ms_defaultCountry = gs_CaptureCountry
End Sub

Private Sub grd_search_ItemSelected()
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:grd_search_DblClick"
    #End If

    ValidSelection

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:grd_search_DblClick"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SeekForm:grd_search_DblClick"
    CapMouseOn
End Sub

Private Sub opt_criteria_Click(Index As Integer)
Dim ls_searchProcStoc As String

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:opt_criteria_Click", "Index=" & Index
    #End If

    If ms_cboCriteriaProcStoc(Index) <> "" Then
        mtxtLike = False
        fra_like.Visible = False
        fra_equal.Visible = True
        cbo_equal.Clear
        cbo_equal.FirstBlankItem = True
        cbo_equal.SearchPrefix = ms_cboCriteriaSearchPrefix(Index)
        ls_searchProcStoc = ms_cboCriteriaProcStoc(WhichOptIsTrue(opt_criteria, mi_nbOfCriteria - 1))
        ls_searchProcStoc = Replace(ls_searchProcStoc, "$CG$", "'" & ms_CGCode & "'")
        cbo_equal.Request = ls_searchProcStoc
        mb_UseOfLike = False
        
        If ms_filter(Index) <> "" Then
            cbo_equal.Load
            cbo_equal.SearchItem ms_filter(Index), 0
        End If
        cbo_equal.SetFocus
    Else
        mtxtLike = True
        fra_equal.Visible = False
        fra_like.Visible = True
        mb_UseOfLike = True
        
        opt_like(0).Visible = True
        opt_like(1).Visible = True
        opt_like(2).Visible = True

        ' Here is a patch for special case
        ' I Use a select case because perhaps there is another case i will see later
        Select Case ms_ComponentType
            Case "PROJECT"
                Select Case Index
                    Case 6 ' Project Size, should not use like, it's greater
                        opt_like(0).Visible = False
                        opt_like(1).Visible = False
                        opt_like(2).Visible = False
                        mb_UseOfLike = False
                End Select
        End Select
        txt_like.Text = Replace(ms_filter(Index), "%", "")
        txt_like.SelStart = 0
        txt_like.SelLength = Len(txt_like.Text)
        
        DoEvents
        If mtxtLike Then
            If txt_like.Enabled = True Then txt_like.SetFocus
        Else
            cbo_equal.SetFocus
        End If
    End If
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:opt_criteria_Click"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SeekForm:opt_criteria_Click"
    CapMouseOn
End Sub

Private Sub tb_top_Action(ByVal as_ActionType As String)
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:tb_top_Action", "as_ActionType=" & as_ActionType
    #End If

    Select Case UCase$(as_ActionType)
    Case "VALID"
        ValidSelection
    Case "FIND"
        FindData
    Case "UNDO"
        RefreshFilters
        grd_search.Visible = False
    Case "QUIT"
        mb_SelectedData = False
        Me.Hide
        
    Case UCase$("Excel")
        
        Select Case ms_ComponentType
            Case "PROJECT"
                If grd_search.Rows <> 0 Then ExportExcel mo_ArmDb, mb_use_framework_connection, ms_ConnectString, m_Language, grd_search, DataTypeEnum.project_search
            Case "CUSTOMER"
                If grd_search.Rows <> 0 Then ExportExcel mo_ArmDb, mb_use_framework_connection, ms_ConnectString, m_Language, grd_search, DataTypeEnum.customer_search
            Case "CONTACT"
                If grd_search.Rows <> 0 Then ExportExcel mo_ArmDb, mb_use_framework_connection, ms_ConnectString, m_Language, grd_search, DataTypeEnum.Contact_Search
            Case "ACTION"
                If grd_search.Rows <> 0 Then ExportExcel mo_ArmDb, mb_use_framework_connection, ms_ConnectString, m_Language, grd_search, DataTypeEnum.Action_Search
            Case "PRODUCT"
                If grd_search.Rows <> 0 Then ExportExcel mo_ArmDb, mb_use_framework_connection, ms_ConnectString, m_Language, grd_search, DataTypeEnum.Product_Search
        End Select
        


    Case UCase$("Print")
        
        
        Select Case ms_ComponentType
            Case "PROJECT"
                If grd_search.SelectedCount = 0 Then
                    Call ASC_SendMessage(mo_ArmDb, m_Language, 921, "#Please, select a line")
                Else
                    Report mo_ArmDb, mb_use_framework_connection, ms_ConnectString, m_Language, grd_search, DataTypeEnum.project
                End If
            
            Case "CUSTOMER"
                If grd_search.SelectedCount = 0 Then
                    Call ASC_SendMessage(mo_ArmDb, m_Language, 921, "#Please, select a line")
                Else
                    Report mo_ArmDb, mb_use_framework_connection, ms_ConnectString, m_Language, grd_search, DataTypeEnum.Customer
                End If
        End Select

    End Select
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:tb_top_Action"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SeekForm:tb_top_Action"
    CapMouseOn
End Sub

Private Sub FindData(Optional ab_NotFind As Boolean = False)
Dim ls_searchProcStoc As String
Dim ls_filter As String
Dim ls_Like As String
Dim ls_OptFilter As String
Dim ls_ParamFilter As String
Dim ls_GridFilter As String
Dim ll_BeginParam As Long
Dim ll_EndParam As Long

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:FindData"
    #End If

    ls_searchProcStoc = ms_searchProcStoc
    
    ls_OptFilter = opt_criteria(WhichOptIsTrue(opt_criteria, mi_nbOfCriteria)).Caption
    ls_GridFilter = "(" & ls_OptFilter
    'store the present search criteria
    
    If fra_like.Visible = True Then
        If mb_UseOfLike = True Then
            Select Case WhichOptIsTrue(opt_like, 2)
                Case 0:
                    ls_filter = SQLStr(txt_like.Text) & "%"
                Case 1:
                    ls_filter = "%" & SQLStr(txt_like.Text) & "%"
                Case 2:
                    ls_filter = "%" & SQLStr(txt_like.Text)
            End Select
        Else
            ls_filter = SQLStr(txt_like.Text)
        End If
            
        ls_ParamFilter = opt_like(WhichOptIsTrue(opt_like, 2)).Caption & " """ & SQLStr(txt_like.Text) & """"
        ls_GridFilter = ls_GridFilter & " " & ls_ParamFilter & ")"
        
    Else
        ls_ParamFilter = " = " & " """ & GetTextFromCombo(cbo_equal) & """"
        ls_GridFilter = ls_GridFilter & " " & ls_ParamFilter & ")"
        ls_filter = GetCodeFromCombo(cbo_equal)
    End If
    ms_filter(WhichOptIsTrue(opt_criteria, mi_nbOfCriteria)) = ls_filter
    
    'replace all $$ in the query
    ReplaceInString ls_searchProcStoc
    
    If Not ErrorFound Then
        'load Grid with this query
        If ms_GridFilter = "" Then
            ms_GridFilter = ls_GridFilter
        Else
            ll_BeginParam = InStr(1, ms_GridFilter, ls_OptFilter, vbTextCompare)
            If ll_BeginParam = 0 Then
                ms_GridFilter = ms_GridFilter & " & " & ls_GridFilter
            Else
                ll_BeginParam = ll_BeginParam + Len(ls_OptFilter)
                ll_EndParam = InStr(ll_BeginParam, ms_GridFilter, ")", vbTextCompare)
                ms_GridFilter = Mid(ms_GridFilter, 1, ll_BeginParam) & ls_ParamFilter & Mid(ms_GridFilter, ll_EndParam, Len(ms_GridFilter) - ll_EndParam + 1)
            End If
        End If
        txt_GridFilter.Text = ms_GridFilter
        
        If ab_NotFind = True Then GoTo Trace_End
            
        grd_search.Visible = True
        grd_search.Requests = ls_searchProcStoc
        If grd_search.Execute = False Then
            If Not go_Trace Is Nothing Then go_Trace.WriteTraceSQLError grd_search.ArmDb, "SeekForm:FindData", "Requests=", grd_search.Requests
        End If
    End If
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:FindData"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SeekForm:FindData"
    CapMouseOn
End Sub

Private Sub ReplaceInString(as_searchproc As String)
Dim i As Integer

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:ReplaceInString", "as_searchproc=" & as_searchproc
    #End If

    ErrorOFF

    'replace the $$ in the query
    as_searchproc = Replace(as_searchproc, "$CT$", CorrectCodeStr(mo_ArmDb, m_Language, cbo_country, False))
    as_searchproc = Replace(as_searchproc, "$lang$", "'" & m_Language & "'")
    For i = 0 To mi_nbOfCriteria - 1
        If ms_filter(i) <> "" Then
            as_searchproc = Replace(as_searchproc, "$" & CStr(i) & "$", FormatSqlStringParameter(ms_filter(i)))
        Else
            as_searchproc = Replace(as_searchproc, "$" & CStr(i) & "$", "NULL")
        End If
    Next i
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:ReplaceInString"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SeekForm:ReplaceInString"
    CapMouseOn
End Sub

Private Function RefreshFilters()
Dim i As Integer

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:RefreshFilters"
    #End If

    For i = 0 To mi_nbOfCriteria - 1
        ms_filter(i) = ""
        If ms_ComponentType = "PRODUCT" And i > 0 And i < 10 Then
            opt_criteria(i).Enabled = False
        End If
    Next i
    ms_CGCode = ""
    ms_GridFilter = ""
    txt_GridFilter.Text = ""
    
    opt_like(0).Value = True
    opt_criteria(0).Value = True
    txt_like.Text = ""
    Set cbo_equal.SelectedItem = Nothing
    grd_search.Visible = False
    
    ms_SelectedItemCode = ""
    ms_SelectedItemDesc = ""
    mSelectedItemFull = ""
        
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:RefreshFilters", "Result=" & RefreshFilters
    #End If
    CapMouseOn
    Exit Function
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SeekForm:RefreshFilters"
    CapMouseOn
End Function

Private Function WhichOptIsTrue(ByRef ao_opt As Object, ai_maxIndex As Integer) As Integer
Dim i As Integer
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:WhichOptIsTrue", "ai_maxIndex=" & ai_maxIndex
    #End If

    For i = 0 To ai_maxIndex
        If ao_opt(i).Value = True Then
            WhichOptIsTrue = i
            GoTo Trace_End
        End If
    Next i
    WhichOptIsTrue = 0
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:WhichOptIsTrue", "Result=" & WhichOptIsTrue
    #End If
    CapMouseOn
    Exit Function
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SeekForm:WhichOptIsTrue"
    CapMouseOn
End Function

Private Sub InitControls()
Dim i As Integer
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:InitControls"
    #End If

    cbo_country.FirstBlankItem = True
    cbo_country.Request = "exec Countries_cbo6 '" & m_Language & "'"
    cbo_country.Load
    cbo_country.SearchItem ms_defaultCountry, 0
    
    
    InitBusinessObject
    
    'toolbar
    tb_top.ClearAllIcons
    
    If ms_ComponentType = "PROJECT" Or ms_ComponentType = "CUSTOMER" Then
        tb_top.PictureDisplayed = "P_Valid=1 P_Find=3 P_UnDo=2 P_Print=-6 P_Excel=-3 P_Quit=-1"
    Else
        tb_top.PictureDisplayed = "P_Valid=1 P_Find=3 P_UnDo=2 P_Excel=-3 P_Quit=-1"
    End If
    tb_top.Refresh
    
    If Not ASC_ConnectToDB(mo_ArmDb, ms_ConnectString, mb_Created) Then GoTo Trace_End
    
    'option buttons
    For i = 0 To mi_nbOfCriteria - 1
        opt_criteria(i).Visible = True
        If ms_ComponentType = "PRODUCT" And i > 0 And i < 10 Then
            opt_criteria(i).Enabled = False
        End If
    Next i
    For i = mi_nbOfCriteria To opt_criteria.Count - 1
        opt_criteria(i).Visible = False
    Next i
    
    'show the good frame
    If ms_cboCriteriaProcStoc(0) <> "" Then
        fra_like.Visible = False
        fra_equal.Visible = True
        cbo_equal.Clear
        cbo_equal.FirstBlankItem = True
        cbo_equal.SearchPrefix = ms_cboCriteriaSearchPrefix(0)
        cbo_equal.Request = ms_cboCriteriaProcStoc(WhichOptIsTrue(opt_criteria, mi_nbOfCriteria - 1))
        mb_UseOfLike = False
    Else
        fra_equal.Visible = False
        fra_like.Visible = True
        mb_UseOfLike = True
    End If
    
    'Default Values
    SetDefaultValues "Cap_SeekForm"
    DisplayDefaultValues
    
    txt_TvFilters.Text = ms_TreeViewFiltersDesc
    
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:InitControls"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SeekForm:InitControls"
    CapMouseOn
End Sub

Private Sub InitBusinessObject()
Dim la_Columns() As String
Dim la_TreeView As Variant
    
    On Error GoTo Trace_Err
    
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:InitBusinessObject"
    #End If

    la_TreeView = Split(ms_TreeViewFilters, CH_LDELIMIT)

    grd_search.MultiSelect = True
    
    Select Case ms_ComponentType
    Case "PROJECT"
        ReDim la_Columns(6)
        
        'Criteria : Name / Addr1 / Addr2 / Town / Zip / Size / SS / PT / PD / NR / PP / SP_CapKey
        ms_ScreenName = "Cap_Project_Search"
' task 298.8 begin
        If ms_viewType = "Vk" Then
            ms_searchProcStoc = "exec CapSearch_Project_A $CT$, $lang$, $folowUpMaxDate$, $0$, $1$, $2$, $3$, $4$, $5$, $6$, $7$, $8$, $9$, $10$, $11$, $12$, $13$, $14$, $15$, '$LOGINNAME$'"
        Else
        ms_searchProcStoc = "exec CapSearch_Project_$DT$ $CT$, $lang$, $opt$, $sa$, $dd$, $df$, $0$, $1$, $2$, $3$, $4$, $5$, $6$, $7$, $8$, $9$, $10$, $11$, $12$, $13$, $14$, $15$,  $sol_sys$"
        End If
' task 298.8 end
        
        If UBound(la_TreeView) = -1 Then        ' FIX system solution
            ReDim la_TreeView(4)
            la_TreeView(4) = "NULL"             ' default value for system solution => All
        End If
        
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$opt$", "'" & la_TreeView(0) & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$sa$", "'" & la_TreeView(1) & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$dd$", "'" & la_TreeView(2) & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$df$", "'" & la_TreeView(3) & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$folowUpMaxDate$", "'" & Format(md_folowUpMaxDate, "MM\/DD\/YYYY") & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$LOGINNAME$", ms_UID)
        ms_searchProcStoc = Replace(ms_searchProcStoc, "''", "NULL")
        
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$sol_sys$", la_TreeView(4))

        SetNbOfCriteria 16
        mi_DescColIndex = 1
        
        la_Columns(0) = "SP_CapKey" & CH_LDELIMIT & "0" & CH_LDELIMIT & "1" & CH_LDELIMIT & "SP_CapKey" & CH_LDELIMIT & "SP_CapKey"
        la_Columns(1) = "SP_Desc" & CH_LDELIMIT & "2000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "SP_Desc" & CH_LDELIMIT & "SP_Desc"
        la_Columns(2) = "SP_Zip" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "SP_Zip" & CH_LDELIMIT & "Zip"
        la_Columns(3) = "SP_Town" & CH_LDELIMIT & "1300" & CH_LDELIMIT & "0" & CH_LDELIMIT & "SP_Town" & CH_LDELIMIT & "Town"
        la_Columns(4) = "SP_size" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "SP_size" & CH_LDELIMIT & "SP_size"
        la_Columns(5) = "SS_Desc" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "SS_Desc" & CH_LDELIMIT & "SS_Desc"
        la_Columns(6) = "SP_FollowUp" & CH_LDELIMIT & "1200" & CH_LDELIMIT & "0" & CH_LDELIMIT & "SP_dateFollowUp" & CH_LDELIMIT & "SP_dateFollowUp"
        
        grd_search.SetColumns la_Columns
        
        ms_cboCriteriaProcStoc(7) = "exec Cap_SalesStatus_cbo '" & ms_UID & "','" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(7) = " "
        ms_cboCriteriaProcStoc(8) = "exec Cap_ProjectType_cbo '" & ms_UID & "','" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(8) = " "
        ms_cboCriteriaProcStoc(9) = "exec Cap_ProjectDescription_cbo '" & ms_UID & "','" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(9) = " "
        ms_cboCriteriaProcStoc(10) = "exec Cap_NewRenovation_cbo '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(10) = ""
        ms_cboCriteriaProcStoc(11) = "exec Cap_ProjectPriority_cbo '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(11) = ""
        
        'screen_csts
        LoadLabels mo_ArmDb, Me.Controls, ms_ScreenName, m_Language
        
        grd_search.LoadConstants ptSQL, "EXEC screen_csts_lst2 '" & ms_ScreenName & "' , 'grid', '" & m_Language & "'", ctColumns
        
        
    Case "CUSTOMER" ' TASK 298.2
        ReDim la_Columns(7)
        
        'Criteria : Name / Addr1 / Addr2 / Town / Zip / Phone / Fax
        ms_ScreenName = "Cap_Customer_Search"
'P516 % sys_code
        ms_searchProcStoc = "exec CapSearch_Customer_$DT$ $CT$, $lang$, $sa$, $dd$, $df$, $0$, $1$, $2$, $3$, $4$, $5$, $6$, $7$, $8$, $dropflag$, $9$"
        
        ' TASK 298.2
        If UBound(la_TreeView) = -1 Then ReDim la_TreeView(3)
    
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$sa$", "'" & la_TreeView(0) & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$dd$", "'" & la_TreeView(1) & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$df$", "'" & la_TreeView(2) & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "''", "NULL")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$dropflag$", la_TreeView(3))
'P516 % sys_code
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$9$", ml_SysCode)
        
        SetNbOfCriteria 9
        mi_DescColIndex = 1
        
        la_Columns(0) = "CCU_CapKey" & CH_LDELIMIT & "0" & CH_LDELIMIT & "1" & CH_LDELIMIT & "CCU_CapKey" & CH_LDELIMIT & "CCU_CapKey"
        la_Columns(1) = "CCU_desc" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_desc" & CH_LDELIMIT & "CCU_desc"
        la_Columns(2) = "CCU_Town" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_Town" & CH_LDELIMIT & "CCU_Town"
        la_Columns(3) = "CCU_Zip" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_Zip" & CH_LDELIMIT & "CCU_Zip"
        la_Columns(4) = "CCU_Tel" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_Tel" & CH_LDELIMIT & "CCU_Phone"
        la_Columns(5) = "CCT_Desc" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCT_Desc" & CH_LDELIMIT & "CCT_Desc"
        la_Columns(6) = "SR_Name" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "SR_Name" & CH_LDELIMIT & "Sales Rep"
        la_Columns(7) = "CP_Desc" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CP_Desc" & CH_LDELIMIT & "CP_Desc"
        
        grd_search.SetColumns la_Columns
        
        
        'screen_csts
        LoadLabels mo_ArmDb, Me.Controls, ms_ScreenName, m_Language
        
        grd_search.LoadConstants ptSQL, "EXEC screen_csts_lst2 '" & ms_ScreenName & "' , 'grid', '" & m_Language & "'", ctColumns
        
    Case "CONTACT"
        ReDim la_Columns(7)
        
        'Criteria : Firstname / Lastname / Phone / Email / JOB / ML
        ms_ScreenName = "Cap_Contact_Search"
        ' BEGIN 298.2
        ms_searchProcStoc = "exec CapSearch_Contact_$DT$ $CT$, $lang$, $0$, $1$, $2$, $3$, $4$, $5$, $6$, $7$, $dropflag$"
        If UBound(la_TreeView) = -1 Then ReDim la_TreeView(0)
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$dropflag$", la_TreeView(0))
        'END 298.2
        
        
        SetNbOfCriteria 8
        mi_DescColIndex = 2
        
        la_Columns(0) = "CNT_code" & CH_LDELIMIT & "0" & CH_LDELIMIT & "1" & CH_LDELIMIT & "CNT_code" & CH_LDELIMIT & "CNT_code"
        la_Columns(1) = "CCU_CapKey" & CH_LDELIMIT & "0" & CH_LDELIMIT & "2" & CH_LDELIMIT & "CCU_CapKey" & CH_LDELIMIT & "CCU_CapKey"
        la_Columns(2) = "CNT_LastName" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CNT_LastName" & CH_LDELIMIT & "LastName"
        la_Columns(3) = "CNT_FirstName" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CNT_FirstName" & CH_LDELIMIT & "First Name"
        la_Columns(4) = "TIT_desc" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "TIT_desc" & CH_LDELIMIT & "TIT_desc"
        la_Columns(5) = "CCU_Desc" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_Desc" & CH_LDELIMIT & "CCU_Desc"
        la_Columns(6) = "JOB_Desc" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "JOB_Desc" & CH_LDELIMIT & "JOB_Desc"
        la_Columns(7) = "CNT_TelOffice" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CNT_TelOffice" & CH_LDELIMIT & "Phone"
        
        grd_search.SetColumns la_Columns
        
        
        ms_cboCriteriaProcStoc(4) = "exec Cap_Job_cbo '" & ms_UID & "','" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(4) = " "
        ms_cboCriteriaProcStoc(5) = "exec Cap_MailingList_cbo '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(5) = " "
        
        'screen_csts
        LoadLabels mo_ArmDb, Me.Controls, ms_ScreenName, m_Language
        grd_search.LoadConstants ptSQL, "EXEC screen_csts_lst2 '" & ms_ScreenName & "' , 'grid', '" & m_Language & "'", ctColumns
        
    Case "ACTION"
        ReDim la_Columns(7)
    
        'Criteria :
        ms_ScreenName = "Cap_Action_Search"
        ms_searchProcStoc = "exec CapSearch_Action_$DT$ $CT$, $lang$, $as$, $dd$, $df$, $0$, $1$, $2$, $3$, $4$, $5$, $6$, $7$, $8$"
        
        If UBound(la_TreeView) = -1 Then ReDim la_TreeView(2)
        
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$as$", "'" & la_TreeView(0) & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$dd$", "'" & la_TreeView(1) & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$df$", "'" & la_TreeView(2) & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "''", "NULL")
        
        
        SetNbOfCriteria 9
        mi_DescColIndex = 3
        
        la_Columns(0) = "AC_code" & CH_LDELIMIT & "0" & CH_LDELIMIT & "1" & CH_LDELIMIT & "AC_code" & CH_LDELIMIT & "AC_code"
        la_Columns(1) = "ACT_DueDate" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "ACT_DueDate" & CH_LDELIMIT & "ACT_DueDate"
        la_Columns(2) = "AT_desc" & CH_LDELIMIT & "1200" & CH_LDELIMIT & "0" & CH_LDELIMIT & "AT_desc" & CH_LDELIMIT & "AT_desc"
        la_Columns(3) = "AS_desc" & CH_LDELIMIT & "1200" & CH_LDELIMIT & "0" & CH_LDELIMIT & "AS_desc" & CH_LDELIMIT & "AS_desc"
        la_Columns(4) = "ACT_RaisedFor" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "ACT_RaisedFor" & CH_LDELIMIT & "ACT_RaisedFor"
        la_Columns(5) = "CNT_name" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CNT_name" & CH_LDELIMIT & "CNT_name"
        la_Columns(6) = "CCU_desc" & CH_LDELIMIT & "2300" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_desc" & CH_LDELIMIT & "CCU_desc"
        la_Columns(7) = "CCU_SAFlag" & CH_LDELIMIT & "300" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_SAFlag" & CH_LDELIMIT & "CCU_SAFlag"
        
        
        
        grd_search.SetColumns la_Columns
        
        
        ms_cboCriteriaProcStoc(2) = "exec Cap_SampleDoc_cbo2 '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(2) = " "
        ms_cboCriteriaProcStoc(4) = "exec Cap_ActionType_cbo '" & ms_UID & "','" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(4) = " "
        ms_cboCriteriaProcStoc(5) = "exec Cap_ActionRaisedBy_cbo '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(5) = ""
        ms_cboCriteriaProcStoc(6) = "exec Cap_ActionRaisedFor_cbo2 '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(6) = ""
        ms_cboCriteriaProcStoc(7) = "exec Cap_ActionReason_cbo '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(7) = " "
        
        'screen_csts
        LoadLabels mo_ArmDb, Me.Controls, ms_ScreenName, m_Language
        
        grd_search.LoadConstants ptSQL, "EXEC screen_csts_lst2 '" & ms_ScreenName & "' , 'grid', '" & m_Language & "'", ctColumns
        
    Case "ACTION_FOLLOWUP"
        ReDim la_Columns(7)
    
        'Criteria :
        ms_ScreenName = "Cap_Action_Search"
        ms_searchProcStoc = "exec CapSearch_Action_$DT$ $CT$, $lang$, $as$, $dd$, $df$, $0$, $1$, $2$, $3$, $4$, $5$, $6$, $7$, $8$"
        
        If UBound(la_TreeView) = -1 Then ReDim la_TreeView(2)
        
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$as$", "'" & la_TreeView(0) & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$dd$", "'" & la_TreeView(1) & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$df$", "'" & la_TreeView(2) & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$6$", "'" & la_TreeView(3) & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "''", "NULL")
        
        
        SetNbOfCriteria 9
        mi_DescColIndex = 3
        
        la_Columns(0) = "AC_code" & CH_LDELIMIT & "0" & CH_LDELIMIT & "1" & CH_LDELIMIT & "AC_code" & CH_LDELIMIT & "AC_code"
        la_Columns(1) = "ACT_DueDate" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "ACT_DueDate" & CH_LDELIMIT & "ACT_DueDate"
        la_Columns(2) = "AT_desc" & CH_LDELIMIT & "1200" & CH_LDELIMIT & "0" & CH_LDELIMIT & "AT_desc" & CH_LDELIMIT & "AT_desc"
        la_Columns(3) = "AS_desc" & CH_LDELIMIT & "1200" & CH_LDELIMIT & "0" & CH_LDELIMIT & "AS_desc" & CH_LDELIMIT & "AS_desc"
        la_Columns(4) = "ACT_RaisedFor" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "ACT_RaisedFor" & CH_LDELIMIT & "ACT_RaisedFor"
        la_Columns(5) = "CNT_name" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CNT_name" & CH_LDELIMIT & "CNT_name"
        la_Columns(6) = "CCU_desc" & CH_LDELIMIT & "2300" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_desc" & CH_LDELIMIT & "CCU_desc"
        la_Columns(7) = "CCU_SAFlag" & CH_LDELIMIT & "300" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_SAFlag" & CH_LDELIMIT & "CCU_SAFlag"
        
        
        
        grd_search.SetColumns la_Columns
        
        
        ms_cboCriteriaProcStoc(2) = "exec Cap_SampleDoc_cbo2 '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(2) = " "
        ms_cboCriteriaProcStoc(4) = "exec Cap_ActionType_cbo '" & ms_UID & "','" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(4) = " "
        ms_cboCriteriaProcStoc(5) = "exec Cap_ActionRaisedBy_cbo '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(5) = ""
        ms_cboCriteriaProcStoc(6) = "exec Cap_ActionRaisedFor_cbo2 '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(6) = ""
        ms_cboCriteriaProcStoc(7) = "exec Cap_ActionReason_cbo '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(7) = " "
        
        'screen_csts
        LoadLabels mo_ArmDb, Me.Controls, ms_ScreenName, m_Language
        
        grd_search.LoadConstants ptSQL, "EXEC screen_csts_lst2 '" & ms_ScreenName & "' , 'grid', '" & m_Language & "'", ctColumns
        
        
        
        
   Case "PRODUCT"
        ReDim la_Columns(10)
        
        'Criteria :
        ms_ScreenName = "Cap_Product_Search"
        'ms_searchProcStoc = "exec Cap_SolutionSystem_t_lst2 $lang$, $CT$, $0$, $1$, $2$, $3$, $4$, $5$, $6$, $7$, $8$, $9$, $10$, $11$, $12$, $13$, $14$"
        ms_searchProcStoc = "exec CapSearch_Product_$DT$ $CT$, $lang$, $opt$, $ma$, $sa$, $dd$, $df$, $0$, $1$, $2$, $3$, $4$, $5$, $6$, $7$, $8$, $9$, $10$, $11$, $12$, $13$, $14$, $15$"
        
        If UBound(la_TreeView) = -1 Then ReDim la_TreeView(4)
        
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$opt$", "'" & la_TreeView(0) & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$ma$", "'" & la_TreeView(1) & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$sa$", "'" & la_TreeView(2) & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$dd$", "'" & la_TreeView(3) & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$df$", "'" & la_TreeView(4) & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "''", "NULL")

        
        SetNbOfCriteria 16
        mi_DescColIndex = 5
        
        la_Columns(0) = "SOL_code" & CH_LDELIMIT & "0" & CH_LDELIMIT & "1" & CH_LDELIMIT & "SOL_code" & CH_LDELIMIT & "SOL_code"
        la_Columns(1) = "S_code" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "2" & CH_LDELIMIT & "S_code" & CH_LDELIMIT & "S_code"
        la_Columns(2) = "MA_desc" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "MA_desc" & CH_LDELIMIT & "MA_desc"
        la_Columns(3) = "S_desc" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "S_desc" & CH_LDELIMIT & "S_desc"
        la_Columns(4) = "PD_Desc" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "PD_Desc" & CH_LDELIMIT & "module"
        la_Columns(5) = "ss_qty" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "ss_qty" & CH_LDELIMIT & "ss_qty"
        la_Columns(6) = "um_desc" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "um_desc" & CH_LDELIMIT & "um_desc"
        la_Columns(7) = "sp_desc" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "sp_desc" & CH_LDELIMIT & "sp_desc"
        la_Columns(8) = "town" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "sp_town" & CH_LDELIMIT & "sp_town"
        la_Columns(9) = "z_creator" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "z_creator" & CH_LDELIMIT & "z_creator"
        la_Columns(10) = "z_creation" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "z_creation" & CH_LDELIMIT & "z_creation"
        
        grd_search.SetColumns la_Columns
                
        ms_cboCriteriaProcStoc(0) = "exec Categories_cbo '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(0) = ""
        ms_cboCriteriaProcStoc(1) = "exec Super_Base_Material_cbo $CG$,'" & m_Language & "'" '"exec Super_Base_Material_cbo2 '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(1) = ""
        ms_cboCriteriaProcStoc(2) = "exec Products_Families_cbo $CG$,'" & m_Language & "'" '"exec Products_Families_cbo5 '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(2) = ""
        ms_cboCriteriaProcStoc(3) = "exec Colours_cbo $CG$,'" & m_Language & "'" '"exec Colours_cbo4 '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(3) = ""
        ms_cboCriteriaProcStoc(4) = "exec Products_Patterns_cbo $CG$,'" & m_Language & "'" '"exec Products_Patterns_cbo4 '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(4) = ""
        ms_cboCriteriaProcStoc(5) = "exec Products_Segmentation_cbo $CG$,'" & m_Language & "'" '"exec Products_Segmentation_cbo4 '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(5) = ""
        ms_cboCriteriaProcStoc(6) = "exec Products_Edges_cbo $CG$,'" & m_Language & "'" '"exec Products_Edges_cbo6 '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(6) = ""
        ms_cboCriteriaProcStoc(7) = "exec Products_Edges_cbo $CG$,'" & m_Language & "'" '"exec Products_Edges_cbo6 '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(7) = ""
        ms_cboCriteriaProcStoc(8) = "exec Surfaces_cbo $CG$,'" & m_Language & "'" '"exec Surfaces_cbo4 '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(8) = ""
        ms_cboCriteriaProcStoc(9) = "exec Product_Module_cbo $CG$,'" & m_Language & "'" '"exec Product_Module_cbo3 '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(9) = ""
        ms_cboCriteriaProcStoc(10) = "exec Cap_InstalledFlag_cbo '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(10) = ""
        ms_cboCriteriaProcStoc(11) = "exec Cap_Competitor_cbo '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(11) = ""
        ms_cboCriteriaProcStoc(12) = "exec Cap_SolutionCreator_cbo"
        ms_cboCriteriaSearchPrefix(12) = ""
        ms_cboCriteriaProcStoc(13) = "exec Cap_Area_cbo '" & m_Language & "'"
        ms_cboCriteriaSearchPrefix(13) = ""
        'ms_cboCriteriaProcStoc(14) = "exec Cap_System_cbo '" & m_Language & "'"
        'ms_cboCriteriaSearchPrefix(14) = ""
        
        'screen_csts
        LoadLabels mo_ArmDb, Me.Controls, ms_ScreenName, m_Language
        grd_search.LoadConstants ptSQL, "EXEC screen_csts_lst2 '" & ms_ScreenName & "' , 'grid', '" & m_Language & "'", ctColumns
        
        
        If la_TreeView(5) = "1" Then
            ms_filter(11) = "1"
            ms_GridFilter = "(" & opt_criteria(11).Caption & " = ""Armstrong"")"
            txt_GridFilter.Text = ms_GridFilter
            opt_criteria(11).Enabled = False
        End If
        
    End Select
    
    ms_searchProcStoc = Replace(ms_searchProcStoc, "$DT$", ms_TreeView_DateType)
    ms_searchProcStoc = Replace(ms_searchProcStoc, "$lang&", "'" & m_Language & "'")
    
    grd_search.Requests = ""

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:InitBusinessObject"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SeekForm:InitBusinessObject"
    CapMouseOn
End Sub

Private Sub SetNbOfCriteria(ai_NbOfCriteria As Integer)
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:SetNbOfCriteria", "ai_NbOfCriteria=" & ai_NbOfCriteria
    #End If

    mi_nbOfCriteria = ai_NbOfCriteria
    ReDim ms_cboCriteriaProcStoc(0 To ai_NbOfCriteria - 1)
    ReDim ms_cboCriteriaSearchPrefix(0 To ai_NbOfCriteria - 1)
    ReDim ms_filter(0 To mi_nbOfCriteria - 1)
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:SetNbOfCriteria"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SeekForm:SetNbOfCriteria"
    CapMouseOn
End Sub

Public Sub Unload_A_COM()

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:Unload_A_COM"
    #End If

    grd_search.Unload_A_COM
    tb_top.Unload_A_COM
    cbo_country.Unload_A_COM
    cbo_equal.Unload_A_COM
    
    ASC_DisconnectFromDB mo_ArmDb, ms_UID, mb_Created
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:Unload_A_COM"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SeekForm:Unload_A_COM"
    CapMouseOn
End Sub

Public Property Get DefaultCountry() As String
    DefaultCountry = ms_defaultCountry
End Property

Public Property Let DefaultCountry(ByVal as_defaultCountry As String)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:DefaultCountry_Let", "as_defaultCountry =" & as_defaultCountry
    #End If
    ms_defaultCountry = as_defaultCountry
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:DefaultCountry_Let"
    #End If
End Property


Public Property Let TreeViewFilters(ByVal as_TreeViewFilters As String)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:TreeViewFilters_Let", "as_TreeViewFilters=" & as_TreeViewFilters
    #End If
    ms_TreeViewFilters = as_TreeViewFilters
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:TreeViewFilters_Let"
    #End If
End Property

Public Property Let TreeViewFiltersDesc(ByVal as_TreeViewFiltersDesc As String)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:TreeViewFiltersDesc_Let", "as_TreeViewFiltersDesc=" & as_TreeViewFiltersDesc
    #End If
    ms_TreeViewFiltersDesc = as_TreeViewFiltersDesc
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:TreeViewFiltersDesc_Let"
    #End If
End Property

Public Property Let TreeView_DateType(ByVal as_TreeView_DateType As String)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:TreeView_DateType_Let", "as_TreeView_DateType=" & as_TreeView_DateType
    #End If
    ms_TreeView_DateType = as_TreeView_DateType
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:TreeView_DateType_Let"
    #End If
End Property

' task298.8 begin
Public Property Let ViewTypeSearch(ByVal as_viewType As String)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:ViewTypeSearch", "as_viewType=" & as_viewType
    #End If
    ms_viewType = as_viewType
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:ViewTypeSearch"
    #End If
End Property
Public Property Let FolowUpMaxDate(ByVal ad_folowUpMaxDate As Date)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:FolowUpMaxDate", "ad_folowUpMaxDate=" & ad_folowUpMaxDate
    #End If
    md_folowUpMaxDate = ad_folowUpMaxDate
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:FolowUpMaxDate"
    #End If
End Property
' task298.8 end

Private Sub txt_like_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        FindData
    End If
End Sub

Function SQLStr(as_Text As String) As String
  SQLStr = Replace(as_Text, "'", "''")
End Function


Private Sub InitBusinessObjectWhenSAP()
'duplicate sub from InitBusinessObject for SAP cust_code search
Dim la_Columns() As String
Dim la_TreeView As Variant
    
    On Error GoTo Trace_Err
    
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SeekForm:InitBusinessObjectWhenSAP"
    #End If

    la_TreeView = Split(ms_TreeViewFilters, CH_LDELIMIT)

    grd_search.MultiSelect = True
    
'P516 begin
    tb_top.ClearAllIcons

    If ms_ComponentType = "CUSTOMER" Then
        tb_top.PictureDisplayed = "P_Valid=1 P_Find=3 P_UnDo=2  P_Quit=-1"
    End If
    tb_top.Refresh
'P516 end
    
    Select Case ms_ComponentType
    Case "PROJECT"
    Case "CUSTOMER" ' TASK 516
        ReDim la_Columns(8)
        
        'Criteria : Name / Addr1 / Addr2 / Town / Zip / Phone / Fax / Cust_Code
        ms_ScreenName = "Cap_Customer_Search"
'P516 % sys_code
        ms_searchProcStoc = "exec CapSearch_CustomerSAP_$DT$ $CT$, $lang$, $sa$, $dd$, $df$, $0$, $1$, $2$, $3$, $4$, $5$, $6$, $7$, $8$, $dropflag$, $9$"
        
        ' TASK 298.2
        If UBound(la_TreeView) = -1 Then ReDim la_TreeView(3)
    
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$sa$", "'" & la_TreeView(0) & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$dd$", "'" & la_TreeView(1) & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$df$", "'" & la_TreeView(2) & "'")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "''", "NULL")
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$dropflag$", la_TreeView(3))
'P516 % sys_code
        ms_searchProcStoc = Replace(ms_searchProcStoc, "$9$", ml_SysCode)
        
        SetNbOfCriteria 9
        mi_DescColIndex = 1
        
        la_Columns(0) = "CCU_CapKey" & CH_LDELIMIT & "0" & CH_LDELIMIT & "1" & CH_LDELIMIT & "CCU_CapKey" & CH_LDELIMIT & "CCU_CapKey"
        la_Columns(1) = "CCU_desc" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_desc" & CH_LDELIMIT & "CCU_desc"
        la_Columns(2) = "CCU_Town" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_Town" & CH_LDELIMIT & "CCU_Town"
        la_Columns(3) = "CCU_Zip" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_Zip" & CH_LDELIMIT & "CCU_Zip"
        la_Columns(4) = "CCU_Tel" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_Tel" & CH_LDELIMIT & "CCU_Phone"
        la_Columns(5) = "CCT_Desc" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCT_Desc" & CH_LDELIMIT & "CCT_Desc"
        la_Columns(6) = "SR_Name" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "SR_Name" & CH_LDELIMIT & "Sales Rep"
        la_Columns(7) = "CP_Desc" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CP_Desc" & CH_LDELIMIT & "CP_Desc"
        la_Columns(8) = "Cust_Code" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "Cust_Code" & CH_LDELIMIT & "Cust_Code"
        
        grd_search.SetColumns la_Columns
        
        
        'screen_csts
        LoadLabels mo_ArmDb, Me.Controls, ms_ScreenName, m_Language
        
        grd_search.LoadConstants ptSQL, "EXEC screen_csts_lst2 '" & ms_ScreenName & "' , 'grid', '" & m_Language & "'", ctColumns
        
    Case "CONTACT"
    Case "ACTION"
    Case "ACTION_FOLLOWUP"
    Case "PRODUCT"
    End Select
    
    ms_searchProcStoc = Replace(ms_searchProcStoc, "$DT$", ms_TreeView_DateType)
    ms_searchProcStoc = Replace(ms_searchProcStoc, "$lang&", "'" & m_Language & "'")
    
    grd_search.Requests = ""

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SeekForm:InitBusinessObjectWhenSAP"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SeekForm:InitBusinessObjectWhenSAP"
    CapMouseOn
End Sub

