VERSION 5.00
Object = "{3A6F7F80-45E5-11D4-AC3E-ADBCE8B30410}#1.0#0"; "vsrpt7.ocx"
Object = "{A8561640-E93C-11D3-AC3B-CE6078F7B616}#1.0#0"; "vsprint7.ocx"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.UserControl Cap_OfferOutPut 
   ClientHeight    =   6300
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   7380
   ScaleHeight     =   6300
   ScaleWidth      =   7380
   Begin VB.CommandButton btn_SaveAsPDF 
      Caption         =   "#Save As PDF"
      Height          =   230
      Left            =   3570
      TabIndex        =   1
      Tag             =   "btn_SaveAsPDF"
      Top             =   15
      Width           =   1212
   End
   Begin VSPrinter7LibCtl.VSPrinter Vp 
      Height          =   6165
      Left            =   0
      TabIndex        =   0
      Top             =   120
      Width           =   7245
      _cx             =   12779
      _cy             =   10874
      Appearance      =   1
      BorderStyle     =   1
      Enabled         =   -1  'True
      MousePointer    =   0
      BackColor       =   -2147483643
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   11.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty HdrFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Courier New"
         Size            =   14.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _ConvInfo       =   1
      AutoRTF         =   -1  'True
      Preview         =   -1  'True
      DefaultDevice   =   0   'False
      PhysicalPage    =   -1  'True
      AbortWindow     =   -1  'True
      AbortWindowPos  =   0
      AbortCaption    =   "Printing..."
      AbortTextButton =   "Cancel"
      AbortTextDevice =   "on the %s on %s"
      AbortTextPage   =   "Now printing Page %d of"
      FileName        =   ""
      MarginLeft      =   1440
      MarginTop       =   1440
      MarginRight     =   1440
      MarginBottom    =   1440
      MarginHeader    =   0
      MarginFooter    =   0
      IndentLeft      =   0
      IndentRight     =   0
      IndentFirst     =   0
      IndentTab       =   720
      SpaceBefore     =   0
      SpaceAfter      =   0
      LineSpacing     =   100
      Columns         =   1
      ColumnSpacing   =   180
      ShowGuides      =   1
      LargeChangeHorz =   300
      LargeChangeVert =   300
      SmallChangeHorz =   30
      SmallChangeVert =   30
      Track           =   0   'False
      ProportionalBars=   -1  'True
      Zoom            =   31.8181818181818
      ZoomMode        =   3
      ZoomMax         =   400
      ZoomMin         =   10
      ZoomStep        =   25
      EmptyColor      =   -2147483636
      TextColor       =   0
      HdrColor        =   0
      BrushColor      =   0
      BrushStyle      =   0
      PenColor        =   0
      PenStyle        =   0
      PenWidth        =   0
      PageBorder      =   0
      Header          =   ""
      Footer          =   ""
      TableSep        =   "|;"
      TableBorder     =   7
      TablePen        =   0
      TablePenLR      =   0
      TablePenTB      =   0
      NavBar          =   3
      NavBarColor     =   -2147483633
      ExportFormat    =   0
      URL             =   ""
      Navigation      =   3
      NavBarMenuText  =   "Whole &Page|Page &Width|&Two Pages|Thumb&nail"
   End
   Begin MSComDlg.CommonDialog dlg_Common 
      Left            =   4800
      Top             =   0
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VSREPORTLibCtl.VSReport Report 
      Left            =   150
      Top             =   150
      _rv             =   700
      _rx             =   405424435
      ReportName      =   ""
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   9
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      OnOpen          =   ""
      OnClose         =   ""
      OnNoData        =   ""
      OnPage          =   ""
      OnError         =   ""
      MaxPages        =   0
      DoEvents        =   -1  'True
      BeginProperty Layout {8F5A70A3-B6D3-11D3-9A1F-800A5BACB530} 
         Width           =   9114
         MarginLeft      =   1440
         MarginTop       =   1440
         MarginRight     =   1440
         MarginBottom    =   1440
         Columns         =   1
         ColumnLayout    =   0
         Orientation     =   1
         PageHeader      =   0
         PageFooter      =   0
         PictureAlign    =   7
         PictureShow     =   1
         PaperSize       =   0
      EndProperty
      BeginProperty DataSource {8F5A70A1-B6D3-11D3-9A1F-800A5BACB530} 
         ConnectionString=   ""
         RecordSource    =   ""
         Filter          =   ""
         MaxRecords      =   0
      EndProperty
      GroupCount      =   0
      SectionCount    =   5
      BeginProperty Section0 {E5849A61-ADD9-11D3-BDEB-000000000000} 
         Name            =   "Detail"
         Visible         =   -1  'True
         Height          =   1335
         CanGrow         =   -1  'True
         CanShrink       =   0   'False
         KeepTogether    =   -1  'True
         ForcePageBreak  =   0
         BackColor       =   16777215
         Repeat          =   0   'False
         OnFormat        =   ""
         OnPrint         =   ""
      EndProperty
      BeginProperty Section1 {E5849A61-ADD9-11D3-BDEB-000000000000} 
         Name            =   "Header"
         Visible         =   -1  'True
         Height          =   1000
         CanGrow         =   -1  'True
         CanShrink       =   0   'False
         KeepTogether    =   -1  'True
         ForcePageBreak  =   0
         BackColor       =   16777215
         Repeat          =   0   'False
         OnFormat        =   ""
         OnPrint         =   ""
      EndProperty
      BeginProperty Section2 {E5849A61-ADD9-11D3-BDEB-000000000000} 
         Name            =   "Footer"
         Visible         =   0   'False
         Height          =   0
         CanGrow         =   -1  'True
         CanShrink       =   0   'False
         KeepTogether    =   -1  'True
         ForcePageBreak  =   0
         BackColor       =   16777215
         Repeat          =   0   'False
         OnFormat        =   ""
         OnPrint         =   ""
      EndProperty
      BeginProperty Section3 {E5849A61-ADD9-11D3-BDEB-000000000000} 
         Name            =   "Page Header"
         Visible         =   0   'False
         Height          =   0
         CanGrow         =   -1  'True
         CanShrink       =   0   'False
         KeepTogether    =   -1  'True
         ForcePageBreak  =   0
         BackColor       =   16777215
         Repeat          =   0   'False
         OnFormat        =   ""
         OnPrint         =   ""
      EndProperty
      BeginProperty Section4 {E5849A61-ADD9-11D3-BDEB-000000000000} 
         Name            =   "Page Footer"
         Visible         =   -1  'True
         Height          =   500
         CanGrow         =   -1  'True
         CanShrink       =   0   'False
         KeepTogether    =   -1  'True
         ForcePageBreak  =   0
         BackColor       =   16777215
         Repeat          =   0   'False
         OnFormat        =   ""
         OnPrint         =   ""
      EndProperty
      FieldCount      =   5
      BeginProperty Field0 {E5849A63-ADD9-11D3-BDEB-000000000000} 
         Name            =   "TitleLbl"
         Text            =   "New Report"
         Object.Left            =   0
         Object.Top             =   95
         Width           =   9024
         Height          =   600
         BackColor       =   16777215
         ForeColor       =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Times New Roman"
            Size            =   24
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Align           =   6
         BackStyle       =   0
         BorderColor     =   0
         BorderStyle     =   0
         CanGrow         =   0   'False
         CanShrink       =   0   'False
         Visible         =   -1  'True
         HideDuplicates  =   0   'False
         RunningSum      =   0
         Format          =   ""
         LineSlant       =   0
         LineWidth       =   0
         PictureAlign    =   0
         MarginLeft      =   0
         MarginTop       =   0
         MarginRight     =   0
         MarginBottom    =   0
         Section         =   1
         ForcePageBreak  =   0
         Calculated      =   0   'False
         WordWrap        =   -1  'True
         LineSpacing     =   0
         CheckBox        =   0
         RTF             =   0   'False
      EndProperty
      BeginProperty Field1 {E5849A63-ADD9-11D3-BDEB-000000000000} 
         Name            =   "FooterLeft"
         Text            =   "Now()"
         Object.Left            =   0
         Object.Top             =   30
         Width           =   4512
         Height          =   300
         BackColor       =   16777215
         ForeColor       =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Align           =   0
         BackStyle       =   0
         BorderColor     =   0
         BorderStyle     =   0
         CanGrow         =   0   'False
         CanShrink       =   0   'False
         Visible         =   -1  'True
         HideDuplicates  =   0   'False
         RunningSum      =   0
         Format          =   ""
         LineSlant       =   0
         LineWidth       =   0
         PictureAlign    =   0
         MarginLeft      =   0
         MarginTop       =   0
         MarginRight     =   0
         MarginBottom    =   0
         Section         =   4
         ForcePageBreak  =   0
         Calculated      =   -1  'True
         WordWrap        =   -1  'True
         LineSpacing     =   0
         CheckBox        =   0
         RTF             =   0   'False
      EndProperty
      BeginProperty Field2 {E5849A63-ADD9-11D3-BDEB-000000000000} 
         Name            =   "FooterRight"
         Text            =   """Page "" & [Page] & "" of "" & [Pages]"
         Object.Left            =   4512
         Object.Top             =   30
         Width           =   4512
         Height          =   300
         BackColor       =   16777215
         ForeColor       =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Align           =   2
         BackStyle       =   0
         BorderColor     =   0
         BorderStyle     =   0
         CanGrow         =   0   'False
         CanShrink       =   0   'False
         Visible         =   -1  'True
         HideDuplicates  =   0   'False
         RunningSum      =   0
         Format          =   ""
         LineSlant       =   0
         LineWidth       =   0
         PictureAlign    =   0
         MarginLeft      =   0
         MarginTop       =   0
         MarginRight     =   0
         MarginBottom    =   0
         Section         =   4
         ForcePageBreak  =   0
         Calculated      =   -1  'True
         WordWrap        =   -1  'True
         LineSpacing     =   0
         CheckBox        =   0
         RTF             =   0   'False
      EndProperty
      BeginProperty Field3 {E5849A63-ADD9-11D3-BDEB-000000000000} 
         Name            =   "Label"
         Text            =   "Label"
         Object.Left            =   720
         Object.Top             =   450
         Width           =   1260
         Height          =   270
         BackColor       =   16777215
         ForeColor       =   0
         Align           =   -1
         BackStyle       =   0
         BorderColor     =   0
         BorderStyle     =   0
         CanGrow         =   0   'False
         CanShrink       =   0   'False
         Visible         =   -1  'True
         HideDuplicates  =   0   'False
         RunningSum      =   0
         Format          =   ""
         LineSlant       =   0
         LineWidth       =   0
         PictureAlign    =   0
         MarginLeft      =   0
         MarginTop       =   0
         MarginRight     =   0
         MarginBottom    =   0
         Section         =   0
         ForcePageBreak  =   0
         Calculated      =   0   'False
         WordWrap        =   -1  'True
         LineSpacing     =   0
         CheckBox        =   0
         RTF             =   0   'False
      EndProperty
      BeginProperty Field4 {E5849A63-ADD9-11D3-BDEB-000000000000} 
         Name            =   "Calculated Field"
         Text            =   "weqweqw"
         Object.Left            =   2610
         Object.Top             =   360
         Width           =   1170
         Height          =   360
         BackColor       =   16777215
         ForeColor       =   0
         Align           =   -1
         BackStyle       =   0
         BorderColor     =   0
         BorderStyle     =   0
         CanGrow         =   0   'False
         CanShrink       =   0   'False
         Visible         =   -1  'True
         HideDuplicates  =   0   'False
         RunningSum      =   0
         Format          =   ""
         LineSlant       =   0
         LineWidth       =   0
         PictureAlign    =   0
         MarginLeft      =   0
         MarginTop       =   0
         MarginRight     =   0
         MarginBottom    =   0
         Section         =   0
         ForcePageBreak  =   0
         Calculated      =   -1  'True
         WordWrap        =   -1  'True
         LineSpacing     =   0
         CheckBox        =   0
         RTF             =   0   'False
      EndProperty
   End
End
Attribute VB_Name = "Cap_OfferOutPut"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Private Const SEP = "®©"
Private Const C_SEP As String = "@@"
Private Const SEP1 As String = "®"
Private Const SEP2 As String = "©"
Private Const SCREEN_NAME As String = "Cap_OfferOutput"


Private mb_Initialized              As Boolean

Const C_ERRORRAISE As Long = 3000

Private Enum ArmErr
    DBCnxFailed = C_ERRORRAISE + 1             ' Unable to connect to the database
    CPTAlreadyInitialized = C_ERRORRAISE + 2   ' We try to initialize a component that is already initialized
    CPTNotInitialized = C_ERRORRAISE + 3       ' We try to use or free that is not initialized yet
    InvalidArgument = C_ERRORRAISE + 4
    PropertyNotSet = C_ERRORRAISE + 5
    SQLFailure = C_ERRORRAISE + 6               ' A SQL runtime error has occured : syntax wrong....
    SQLBadRowAffectedCount = C_ERRORRAISE + 7   ' A SQL request has not affected the expected rowcount (ex: one Update do nothing)
    SQLBadRowExpectedCount = C_ERRORRAISE + 8   ' A SQL request does not return the expected rowcount : select an item return nothing...
    DrivingError = C_ERRORRAISE + 9
    CompFncFailed = C_ERRORRAISE + 10           ' when component function fail
    GridLoadFailed = C_ERRORRAISE + 11          ' load function failed ... bad sql
End Enum

Private Enum ArmCusErr
    DuplicityDetected = C_ERRORRAISE + 2301                ' detected row with same unique id
    UnableDeleteFile = C_ERRORRAISE + 6848          ' file blocked
End Enum


Private Type SQLcursorData
    Request     As String
    HEADERS()   As String
    Rows()      As Variant
End Type

Private Type ParamInfo
    Name As String
    Value As Variant
    Type As ArmSysType
End Type

Private Type ReportInfo
    Name As String
    Request As String
    Clear As Boolean
    SQLParams() As ParamInfo
End Type

Private Type ReportParams
    PathReport As String
    Name As String
    Report_Language As String
    Report_CodePage As Long
    FontName As String
    
    ReportInfo() As ReportInfo
    'COF_Id As String
    'COT_Id As String
    'PrintTotal As Boolean
    'PrintReps As Boolean
End Type


#If ENV = LIVE Then
Private mo_Db As Object
Private mo_FSO As Object
#Else
Private mo_Db As ARMSYSCOMLib.ArmDb
Private mo_FSO As FileSystemObject
#End If

Private mo_Tools As DPC_Tools

Private ms_Server As String
Private ms_DBName As String
Private ms_PW As String
Private ms_ExternalSepString As String
Private ms_DPCImageCachePath As String
Private ml_U_Code As Long
Private ms_LoginName As String
Private ms_Language_Code As String
Private ms_Caption As String
Private mc_ScreenLabels As Long

Private mo_cursorData() As SQLcursorData        ' array of data copied from sql cursors opened for template
Private mo_ReportParams As ReportParams

Private mo_VSDataSrcCol As New Collection

Public Property Set Tools(ByRef ao_Tools As Object)
On Error GoTo ErrorHandler

  Set mo_Tools = ao_Tools
  Exit Property
ErrorHandler:
  Call ErrorHandler("Tools.Set")
End Property

Public Property Set ArmDb(ByRef ao_Db As Object)
On Error GoTo ErrorHandler

  Set mo_Db = ao_Db
  Exit Property
ErrorHandler:
  Call ErrorHandler("ArmDb.Set")
End Property

Public Property Let Language_Code(ByVal as_Language_Code As String)
On Error GoTo ErrHandler
  
  ms_Language_Code = as_Language_Code
  Exit Property
ErrHandler:
  Call ErrorHandler("Language_Code.Let")
End Property

Public Property Get Language_Code() As String
On Error GoTo ErrHandler
  
  Language_Code = ms_Language_Code
  Exit Property
ErrHandler:
  Call ErrorHandler("Language_Code.Get")
End Property

Public Property Let U_Code(ByVal al_U_Code As Long)
On Error GoTo ErrorHandler

  ml_U_Code = al_U_Code
  Exit Property
ErrorHandler:
  Call ErrorHandler("U_Code.Let")
End Property

Public Property Let LoginName(ByVal as_Value As String)
On Error GoTo ErrorHandler

  ms_LoginName = as_Value
  Exit Property
ErrorHandler:
  Call ErrorHandler("LoginName.Let")
End Property

Public Property Let Caption(ByVal as_Value As String)
On Error GoTo ErrHandler
    
  ms_Caption = as_Value
  Exit Property
ErrHandler:
  Call ErrorHandler("Caption.Let")
End Property

Public Property Get Caption() As String
On Error GoTo ErrHandler
    
  Caption = ms_Caption
  Exit Property
ErrHandler:
  Call ErrorHandler("Caption.Get")
End Property

Public Property Let Name(ByVal as_Value As String)
On Error GoTo ErrHandler
    
  UserControl.Extender.Name = as_Value
  Exit Property
ErrHandler:
  Call ErrorHandler("Name.Let")
End Property

Public Property Get Name() As String
On Error GoTo ErrHandler
    
  Name = UserControl.Extender.Name
  Exit Property
ErrHandler:
  Call ErrorHandler("Name.Get")
End Property

Public Property Let Tag(ByVal as_Value As String)
On Error GoTo ErrHandler
    
  UserControl.Tag = as_Value
  Exit Property
ErrHandler:
  Call ErrorHandler("Tag.Let")
End Property

Public Property Get Tag() As String
On Error GoTo ErrHandler
    
  Tag = UserControl.Tag
  Exit Property
ErrHandler:
  Call ErrorHandler("Tag.Get")
End Property

Public Property Let Visible(ByVal aVisible As Boolean)
On Error GoTo ErrHandler
    
  UserControl.Extender.Visible = aVisible
  Exit Property
ErrHandler:
  Call ErrorHandler("Visible.Let")
End Property

Public Property Get Visible() As Boolean
On Error GoTo ErrHandler
    
  Visible = UserControl.Extender.Visible
  Exit Property
ErrHandler:
  Call ErrorHandler("Visible.Get")
End Property

Public Property Let Top(ByVal aTop As Single)
On Error GoTo ErrHandler
    
  UserControl.Extender.Top = aTop
  Exit Property
ErrHandler:
  Call ErrorHandler("Top.Let")
End Property

Public Property Get Top() As Single
On Error GoTo ErrHandler
    
  Top = UserControl.Extender.Top
  Exit Property
ErrHandler:
  Call ErrorHandler("Top.Get")
End Property

Public Property Let Height(ByVal aHeight As Single)
On Error GoTo ErrHandler
    
  UserControl.Extender.Height = aHeight
  Exit Property
ErrHandler:
  Call ErrorHandler("Height.Let")
End Property

Public Property Get Height() As Single
On Error GoTo ErrHandler
    
  Height = UserControl.Extender.Height
  Exit Property
ErrHandler:
  Call ErrorHandler("Height.Get")
End Property

Public Property Let Left(ByVal aLeft As Single)
On Error GoTo ErrHandler
    
  UserControl.Extender.Left = aLeft
  Exit Property
ErrHandler:
  Call ErrorHandler("Left.Let")
End Property

Public Property Get Left() As Single
On Error GoTo ErrHandler
    
  Left = UserControl.Extender.Left
  Exit Property
ErrHandler:
  Call ErrorHandler("Left.Get")
End Property

Public Property Let Width(ByVal aWidth As Single)
On Error GoTo ErrHandler
    
  UserControl.Extender.Width = aWidth
  Exit Property
ErrHandler:
  Call ErrorHandler(".Let")
End Property

Public Property Get Width() As Single
On Error GoTo ErrHandler
    
  Width = UserControl.Extender.Width
  Exit Property
ErrHandler:
  Call ErrorHandler("Width.Get")
End Property

Public Sub Move(ByVal aLeft As Single, ByVal aTop As Single, ByVal aWidth As Single, ByVal aHeight As Single)
On Error GoTo ErrHandler
  
  Call UserControl.Extender.Move(aLeft, aTop, aWidth, aHeight)
  Exit Sub
ErrHandler:
  Call ErrorHandler("Move")
End Sub

Public Property Let Enabled(ByVal ab_Value As Boolean)
On Error GoTo ErrHandler

  UserControl.Enabled = ab_Value
  Exit Property
ErrHandler:
  Call ErrorHandler("Enabled.Let")
End Property

Public Property Get Enabled() As Boolean
 On Error GoTo ErrHandler

  Enabled = UserControl.Enabled
  Exit Property
ErrHandler:
  Call ErrorHandler("Enabled.Get")
End Property

Public Sub Zorder()
On Error GoTo ErrHandler

  Call UserControl.Extender.Zorder
  Exit Sub
ErrHandler:
  Call ErrorHandler("Zorder")
End Sub

Public Sub Refresh()
On Error GoTo ErrHandler

  Call UserControl.Refresh
  Exit Sub
ErrHandler:
  Call ErrorHandler("Refresh")
End Sub

Public Property Get hwnd() As Long
On Error GoTo ErrHandler
  
  hwnd = UserControl.hwnd
  Exit Property
ErrHandler:
  Call ErrorHandler("hwnd.Get")
End Property

Public Property Get Initialized() As Boolean
On Error GoTo ErrHandler
    
  Initialized = mb_Initialized
  Exit Property
ErrHandler:
  Call ErrorHandler("Initialized.Get")
End Property

Public Property Let navBar(ByVal al_Type As NavBarSettings)
    Vp.navBar = al_Type
End Property
Public Property Get navBar() As NavBarSettings
    navBar = Vp.navBar
End Property

Public Property Let ExternalSepString(as_SepString As String)
    ms_ExternalSepString = as_SepString
End Property

Public Function Load_A_COM() As Boolean

On Error GoTo ErrHandler

  If mb_Initialized Then Exit Function
  
  If mo_Db Is Nothing Then
      Call Err.Raise(ArmErr.PropertyNotSet)
  End If
  If mo_Tools Is Nothing Then
      Call Err.Raise(ArmErr.PropertyNotSet)
  End If
  
  Call mo_Tools.Load_A_ComControls(UserControl.Controls, mo_Db, ms_Language_Code)
  
  Set mo_FSO = New FileSystemObject

  ReDim mo_cursorData(-1 To -1) As SQLcursorData
  ReDim mo_cursorData(-1).HEADERS(-1 To -1) As String
  ReDim mo_cursorData(-1).Rows(-1 To -1) As Variant
  
  ms_DPCImageCachePath = prg.AppCache_Dir & DPC_IMAGE_CACHE
  Call InitComponents
  ms_ExternalSepString = ""
  
  'Screen csts
  mc_ScreenLabels = mo_Tools.LoadLabels(mo_Db, UserControl.Controls, Me, SCREEN_NAME, ms_Language_Code)
  Call mo_Tools.ChangeCharset(UserControl.Controls, gl_CodePage)
  
  mb_Initialized = True
  Load_A_COM = True
  Exit Function
ErrHandler:
  Call ErrorHandler("Load_A_Com")
End Function

Public Function Unload_A_COM() As Boolean

On Error GoTo ErrHandler

Dim lo_VSDataSource As VSDataSource

  If Not mb_Initialized Then Exit Function
  
  Call mo_Tools.Unload_A_ComControls(UserControl.Controls)
  Call mo_Db.Close(mc_ScreenLabels)
  Set mo_FSO = Nothing
  Set mo_Db = Nothing
  mb_Initialized = False
  
    While mo_VSDataSrcCol.Count > 0
        Set lo_VSDataSource = mo_VSDataSrcCol.Item(1)
        Call lo_VSDataSource.Unload_A_COM
        Set lo_VSDataSource = Nothing
        Call mo_VSDataSrcCol.Remove(1)
    Wend
    
    Set mo_VSDataSrcCol = Nothing
    
  Unload_A_COM = True
  Exit Function
ErrHandler:
    Call ErrorHandler("Unload_A_Com")
End Function


Private Sub InitComponents()

On Error GoTo ErrHandler
  
Dim lo_Control As Control

  Exit Sub
ErrHandler:
  Call ErrorHandler("InitComponents")
End Sub

Private Function CheckTemplateExist(ByVal as_DownloadFolder As String, ByVal as_PartFolderName As String, ByVal ai_COTZ_ID As Integer) As Boolean
On Error GoTo ErrHandler
    
#If LIVE Then
    Dim lo_FSO As Object
    Set lo_FSO = CreateObject("Scripting.FileSystemObject")
#Else
    Dim lo_FSO As FileSystemObject
    Set lo_FSO = New FileSystemObject
#End If
    
    If Not lo_FSO.FolderExists(as_DownloadFolder & as_PartFolderName & ai_COTZ_ID & "\") Then
        
        If Not mo_Db.BlobToFileSQL("exec Cap_OfferTemplateZip_sel " & ai_COTZ_ID, as_DownloadFolder & "OfferTmpZip" & ai_COTZ_ID, 9) Then
          Err.Raise ArmErr.CompFncFailed, "BlobToFileSQL", "Template download failed: " & mo_Db.LastErrorMessage
        End If
        
        If Not mo_Db.DecompressFile(as_DownloadFolder & "OfferTmpZip" & ai_COTZ_ID, as_DownloadFolder & as_PartFolderName & ai_COTZ_ID & "\", True, True) Then
          Err.Raise ArmErr.CompFncFailed, "DecompressFile", "Template decompress failed: " & mo_Db.LastErrorMessage
        End If
        
    End If
    
    Set lo_FSO = Nothing
    
    CheckTemplateExist = True
    
    Exit Function
ErrHandler:

    Call ErrorHandler("CheckTemplateExist")
End Function

Public Function PrintOffer(ByVal as_COF_Id As String, ByVal al_COT_Id As Long, ByVal al_COTZ_Id As Long, ByVal as_DownloadFolder As String, ByVal as_COTZ_FolderName As String, ByVal as_Report_Language As String, ByVal al_Report_CodePage As Long, ByVal ab_PrintPictures As Boolean, ByVal ab_PrintTotal As Boolean, ByVal ab_PrintReps As Boolean, Optional ab_SaveAsPDF = False, Optional ab_InterCompany = False, Optional ab_PrintGeneralTerms = True, Optional ByVal ab_PrintASItemMessage As Boolean = False) As Boolean
On Error GoTo ErrHandler
    Dim ls_downloadFolder As String
    Dim ll_Index As Long
    
    ls_downloadFolder = CheckFolderExist(as_DownloadFolder)
    
    If CheckTemplateExist(ls_downloadFolder, as_COTZ_FolderName, al_COTZ_Id) Then
    
        mo_ReportParams.PathReport = ls_downloadFolder & as_COTZ_FolderName & al_COTZ_Id & "\OfferTmp.xml"
        mo_ReportParams.Name = "Offer"
        mo_ReportParams.FontName = "Arial"
        mo_ReportParams.Report_Language = as_Report_Language
        mo_ReportParams.Report_CodePage = al_Report_CodePage
        
        ReDim mo_ReportParams.ReportInfo(6)
        
        mo_ReportParams.ReportInfo(0).Name = "Offer"
        mo_ReportParams.ReportInfo(1).Name = "OfferHeader"
        mo_ReportParams.ReportInfo(2).Name = "OfferDetail"
        mo_ReportParams.ReportInfo(3).Name = "OfferAlternative"
        mo_ReportParams.ReportInfo(4).Name = "OfferSurcharge"
        mo_ReportParams.ReportInfo(5).Name = "OfferPictures"
        mo_ReportParams.ReportInfo(6).Name = "OfferFooter"
        
        If ab_InterCompany = True Then
            mo_ReportParams.ReportInfo(0).Request = "exec Cap_OffersPrintHeaderInt_sel $COF_ID$,$Language_code$,$PrintReps$"
            mo_ReportParams.ReportInfo(1).Request = "exec Cap_OffersPrintHeaderInt_sel $COF_ID$,$Language_code$,$PrintReps$"
            mo_ReportParams.ReportInfo(2).Request = "exec Cap_OffersPrintDetailInt_sel $COF_ID$,$Language_code$,$PrintTotal$"
            mo_ReportParams.ReportInfo(3).Clear = True
            mo_ReportParams.ReportInfo(4).Clear = True
            mo_ReportParams.ReportInfo(5).Clear = True
            mo_ReportParams.ReportInfo(6).Clear = True
        End If
        
        For ll_Index = 0 To 6
            If ab_InterCompany = False Then
                If ((ab_PrintPictures = False And mo_ReportParams.ReportInfo(ll_Index).Name = "OfferPictures") Or _
                    (ab_PrintGeneralTerms = False And mo_ReportParams.ReportInfo(ll_Index).Name = "OfferFooter")) Then
                    
                    mo_ReportParams.ReportInfo(ll_Index).Clear = True
                Else
                    mo_ReportParams.ReportInfo(ll_Index).Clear = False
                End If
            
                mo_ReportParams.ReportInfo(ll_Index).Request = ""
            End If
            
            If ab_InterCompany = False Or ll_Index < 3 Then
                Call AddSQLParam(mo_ReportParams.ReportInfo(ll_Index).SQLParams, "Language_Code", as_Report_Language, DBTYPE_STR)
                Call AddSQLParam(mo_ReportParams.ReportInfo(ll_Index).SQLParams, "COF_Id", as_COF_Id, DBTYPE_STR)
                Call AddSQLParam(mo_ReportParams.ReportInfo(ll_Index).SQLParams, "PrintTotal", ab_PrintTotal, DBTYPE_BOOL)
                Call AddSQLParam(mo_ReportParams.ReportInfo(ll_Index).SQLParams, "PrintReps", ab_PrintReps, DBTYPE_BOOL)
                Call AddSQLParam(mo_ReportParams.ReportInfo(ll_Index).SQLParams, "PrintAsItemMessage", ab_PrintASItemMessage, DBTYPE_BOOL)
            End If
        Next
        
        If ab_SaveAsPDF = False Then
            Call ExecuteReport(mo_ReportParams, False)
        End If
    End If
        
    PrintOffer = True
    Exit Function
ErrHandler:
    Call ErrorHandler("PrintOffer")
End Function

Public Function PrintOfferPacking(ByVal as_COF_Id As String, ByVal al_COT_Id As Long, ByVal al_COTZ_Id As Long, ByVal as_DownloadFolder As String, ByVal as_COTZ_FolderName As String, ByVal as_Report_Language As String, ByVal al_Report_CodePage As Long, Optional ab_SaveAsPDF = False) As Boolean
On Error GoTo ErrHandler
    Dim ls_downloadFolder As String
    Dim ll_Index As Long
    
    ls_downloadFolder = CheckFolderExist(as_DownloadFolder)
    
    If CheckTemplateExist(ls_downloadFolder, as_COTZ_FolderName, al_COTZ_Id) Then
    
        mo_ReportParams.PathReport = ls_downloadFolder & as_COTZ_FolderName & al_COTZ_Id & "\OfferTmp.xml"
        mo_ReportParams.Name = "OfferPacking"
        mo_ReportParams.FontName = "Arial"
        mo_ReportParams.Report_Language = as_Report_Language
        mo_ReportParams.Report_CodePage = al_Report_CodePage
        
        ReDim mo_ReportParams.ReportInfo(1)
        
        mo_ReportParams.ReportInfo(0).Name = "OfferPacking"
        mo_ReportParams.ReportInfo(1).Name = "OfferPackingDetail"
        
        For ll_Index = 0 To 1
               
          mo_ReportParams.ReportInfo(ll_Index).Clear = False
          mo_ReportParams.ReportInfo(ll_Index).Request = ""
          Call AddSQLParam(mo_ReportParams.ReportInfo(ll_Index).SQLParams, "Language_Code", as_Report_Language, DBTYPE_STR)
          Call AddSQLParam(mo_ReportParams.ReportInfo(ll_Index).SQLParams, "COF_Id", as_COF_Id, DBTYPE_STR)
        Next
        
        If ab_SaveAsPDF = False Then
            Call ExecuteReport(mo_ReportParams, False)
        End If
    End If
        
    PrintOfferPacking = True
    Exit Function
ErrHandler:
    Call ErrorHandler("PrintOfferPacking")
End Function

Public Function SafeUbound2(ByRef av_Array As Variant)
On Error GoTo ErrHandler

    SafeUbound2 = UBound(av_Array)
    Exit Function
ErrHandler:
    'If error is something other than "Subscript out of range", then display the error
    If Err.Number <> 9 Then Err.Raise Err.Number, Err.Source, Err.Description
    SafeUbound2 = -1
End Function

Private Sub AddSQLParam(ByRef ao_Params() As ParamInfo, ByVal as_ParamName As String, ByVal av_ParamValue As Variant, ByVal al_ParamType As ArmSysType)
On Error GoTo ErrHandler
            
    'MW REDIM >>
    Dim ll_UBound As Integer
    Dim ll_Err As Integer
    
    On Error Resume Next
    ll_UBound = UBound(ao_Params)
    ll_Err = Err.Number
    On Error GoTo ErrHandler
    
    If ll_Err = 9 Then
        ll_UBound = -1
        ll_Err = 0
    End If
    
    If ll_Err <> 0 Then
        Err.Raise Err.Number, Err.Source, Err.Description
    End If
    
    'MW <<
    
    If ll_UBound = -1 Then
        ReDim ao_Params(0)
    Else
        ReDim Preserve ao_Params(UBound(ao_Params) + 1)
    End If

    ao_Params(UBound(ao_Params)).Name = as_ParamName
    ao_Params(UBound(ao_Params)).Value = av_ParamValue
    ao_Params(UBound(ao_Params)).Type = al_ParamType
  
  Exit Sub
ErrHandler:
  Call ErrorHandler("AddSQLParam")
End Sub

Private Function CheckFolderExist(ByVal as_Folder As String) As String
    #If LIVE Then
        Dim lo_FSO As Object
        Set lo_FSO = CreateObject("Scripting.FileSystemObject")
    #Else
        Dim lo_FSO As FileSystemObject
        Set lo_FSO = New FileSystemObject
    #End If
    
    Dim ls_Folder As String
        
    ls_Folder = as_Folder
    
    If right(ls_Folder, 1) <> "\" Then ls_Folder = ls_Folder & "\"
    
    If Not lo_FSO.FolderExists(ls_Folder) Then
        Call lo_FSO.CreateFolder(ls_Folder)
    End If
    
    Set lo_FSO = Nothing
        
    CheckFolderExist = ls_Folder
    Exit Function
ErrHandler:
    Set lo_FSO = Nothing
    Call ErrorHandler("CheckFolderExist")
End Function

Public Function SetPrintableArea(ByVal al_left As Long, ByVal al_top As Long, ByVal al_width As Long, ByVal al_height As Long)
On Error GoTo ErrHandler
    Call Vp.Move(al_left, al_top, al_width, al_height)
    Exit Function
ErrHandler:
    Call ErrorHandler("SetPrintableArea")
End Function

Private Function SavePDFFileName() As String
On Error GoTo ErrHandler
    
Dim ls_Filename As String
Dim ll_Ret As Long
       
    SavePDFFileName = ""
    
    dlg_Common.Filter = "PDF files (*.PDF)|*.PDF"
    dlg_Common.CancelError = True
    Call dlg_Common.ShowSave
    
    SavePDFFileName = dlg_Common.FileName
    
    Exit Function
ErrHandler:
    If Err.Number = 32755 Then 'Cancel button clicked
        Err.Clear
    Else
        Call ErrorMessage("SavePDFFileName")
    End If
    
End Function

Private Function ExecuteReport(ByRef ao_ReportParams As ReportParams, Optional ab_SaveAsPDF = False) As Boolean
On Error GoTo ErrHandler
    
    Dim ll_Charset As Long
    
    Dim ll_Index As Long
    Dim ll_Index2 As Long
    
    Dim ls_language As String
    Dim ll_CodePage As Long
    
    Dim lo_VSDataSource As VSDataSource
    
    Dim lo_ReportInfo As ReportInfo
    Dim lb_ReportInfoAvailable As Boolean
    
    Dim ls_PDF_FileName As String
            
    ll_CodePage = ao_ReportParams.Report_CodePage
    ls_language = ao_ReportParams.Report_Language
    
    ll_Charset = mo_Tools.GetCharSetFromCodePage(ll_CodePage)
    
    Vp.Font.Name = ao_ReportParams.FontName
    Vp.Font.Charset = ll_Charset
    
    Vp.Orientation = orPortrait
    Vp.PaperSize = pprA4
    Vp.MarginLeft = 800
    Vp.MarginRight = 800
    Vp.MarginTop = 800
    Vp.MarginBottom = 800
    
    Vp.CurrentX = Vp.MarginLeft
    Vp.CurrentY = Vp.MarginTop
    
    While mo_VSDataSrcCol.Count > 0
        Set lo_VSDataSource = mo_VSDataSrcCol.Item(1)
        Call lo_VSDataSource.Unload_A_COM
        Set lo_VSDataSource = Nothing
        Call mo_VSDataSrcCol.Remove(1)
    Wend
    
    Call Report.Load(ao_ReportParams.PathReport, ao_ReportParams.Name)
    
    If FindReportInfo(Report.ReportName, ao_ReportParams.ReportInfo, lo_ReportInfo) = True Then
    
        Set lo_VSDataSource = New VSDataSource
        Set lo_VSDataSource.ArmDb = mo_Db
        Set lo_VSDataSource.Tools = mo_Tools
        Call lo_VSDataSource.Load_A_COM
        
        If lo_ReportInfo.Request = "" Then
            lo_VSDataSource.DataSourceRequest = Report.DataSource.RecordSource
        Else
            lo_VSDataSource.DataSourceRequest = lo_ReportInfo.Request
        End If
        
        For ll_Index = 0 To UBound(lo_ReportInfo.SQLParams)
            Call lo_VSDataSource.AddParam(lo_ReportInfo.SQLParams(ll_Index).Name, lo_ReportInfo.SQLParams(ll_Index).Value, lo_ReportInfo.SQLParams(ll_Index).Type)
        Next
        
        Call lo_VSDataSource.LoadData
        
        Call mo_VSDataSrcCol.Add(lo_VSDataSource, "0")
        
    End If
    
    Report.Font.Name = ao_ReportParams.FontName
    Report.Font.Charset = ll_Charset
        
    Report.DataSource.Recordset = mo_VSDataSrcCol.Item("0")
    
    For ll_Index = 1 To Report.Fields.Count - 1
    
        If Not Report.Fields.Item(ll_Index).Font Is Nothing Then
            Report.Fields.Item(ll_Index).Font.Name = ao_ReportParams.FontName
            Report.Fields.Item(ll_Index).Font.Charset = ll_Charset
        End If
        
        If Not Report.Fields.Item(ll_Index).Subreport Is Nothing Then
        
          If FindReportInfo(Report.Fields.Item(ll_Index).Subreport, ao_ReportParams.ReportInfo, lo_ReportInfo) = True Then
                    
              If lo_ReportInfo.Clear = True Then
                Call Report.Fields.Item(ll_Index).Subreport.Clear
                
              Else
                Report.Fields.Item(ll_Index).Subreport.Font.Name = ao_ReportParams.FontName
                Report.Fields.Item(ll_Index).Subreport.Font.Charset = ll_Charset
                
                For ll_Index2 = 1 To Report.Fields.Item(ll_Index).Subreport.Fields.Count - 1
                
                    If Not Report.Fields.Item(ll_Index).Subreport.Fields.Item(ll_Index2).Font Is Nothing Then
                        Report.Fields.Item(ll_Index).Subreport.Fields.Item(ll_Index2).Font.Name = ao_ReportParams.FontName
                        Report.Fields.Item(ll_Index).Subreport.Fields.Item(ll_Index2).Font.Charset = ll_Charset
                    End If
                Next
                                        
                Set lo_VSDataSource = New VSDataSource
                Set lo_VSDataSource.ArmDb = mo_Db
                Set lo_VSDataSource.Tools = mo_Tools
                Call lo_VSDataSource.Load_A_COM
                
                If lo_ReportInfo.Request = "" Then
                    lo_VSDataSource.DataSourceRequest = Report.Fields.Item(ll_Index).Subreport.DataSource.RecordSource
                Else
                    lo_VSDataSource.DataSourceRequest = lo_ReportInfo.Request
                End If
                
                For ll_Index2 = 0 To UBound(lo_ReportInfo.SQLParams)
                    Call lo_VSDataSource.AddParam(lo_ReportInfo.SQLParams(ll_Index2).Name, lo_ReportInfo.SQLParams(ll_Index2).Value, lo_ReportInfo.SQLParams(ll_Index2).Type)
                Next
            
                Call lo_VSDataSource.LoadData
                
                Call mo_VSDataSrcCol.Add(lo_VSDataSource, CStr(ll_Index))
            
                Report.Fields.Item(ll_Index).Subreport.DataSource.RecordSource = ""
                Report.Fields.Item(ll_Index).Subreport.DataSource.Recordset = mo_VSDataSrcCol.Item(CStr(ll_Index))
            End If
            
          End If
        End If
    Next ll_Index
                                    
    If ab_SaveAsPDF = False Then
        With Report
            .DoEvents = True ' no message handling until done
            .Render Vp
        End With
    End If
    
    Exit Function
ErrHandler:
    Call ErrorHandler("ExecuteReport")

End Function

Private Function FindReportInfo(ByVal as_Name As String, ByRef ao_ReportInfo() As ReportInfo, ByRef ao_Report As ReportInfo) As Boolean
Dim ll_Index As Long
    
    For ll_Index = 0 To UBound(ao_ReportInfo)
        If ao_ReportInfo(ll_Index).Name = as_Name Then
            ao_Report = ao_ReportInfo(ll_Index)
            FindReportInfo = True
            Exit Function
        End If
    Next
        
    FindReportInfo = False
End Function

Private Function ReplaceTextCursor(ByVal ac_Cursor As Long, ByVal as_Text As String) As String
Dim ll_Field As Long
Dim ls_DBFieldName As String
Dim ls_Data As String

  For ll_Field = 0 To mo_Db.FieldCount(ac_Cursor) - 1
      ls_DBFieldName = mo_Db.GetFieldName(ac_Cursor, ll_Field)
      ' see if data is in serialized string
      ls_Data = Trim(mo_Db.GetFields(ac_Cursor, ll_Field))
      as_Text = Replace(as_Text, "[" & ls_DBFieldName & "]", ls_Data)
  Next
  ReplaceTextCursor = as_Text
End Function

Private Function FormatToText(ByVal av_Value As Variant, ByVal as_Format As String) As String

  If as_Format = "" Then
    FormatToText = Trim(av_Value)
  Else
    If VarType(av_Value) = vbDate Then
      If av_Value = 0 Then
        FormatToText = ""
      Else
        FormatToText = Format(av_Value, as_Format)
      End If
    Else
      FormatToText = Format(av_Value, as_Format)
    End If
  End If
End Function

Private Sub CopyFieldProperties(ByVal ao_FieldSrc As VSREPORTLibCtl.Field, ByVal ao_FieldDst As VSREPORTLibCtl.Field)
On Error GoTo ErrHandler

  ao_FieldDst.Align = ao_FieldSrc.Align
  ao_FieldDst.CanGrow = ao_FieldSrc.CanGrow
  ao_FieldDst.CanShrink = ao_FieldSrc.CanShrink
  ao_FieldDst.Font = ao_FieldSrc.Font
  ao_FieldDst.BorderStyle = ao_FieldSrc.BorderStyle
  ao_FieldDst.Format = ao_FieldSrc.Format
  ao_FieldDst.Picture = ao_FieldSrc.Picture
  ao_FieldDst.PictureAlign = ao_FieldSrc.PictureAlign
  ao_FieldDst.BackColor = ao_FieldSrc.BackColor
  ao_FieldDst.ForeColor = ao_FieldSrc.ForeColor
  ao_FieldDst.BorderColor = ao_FieldSrc.BorderColor
  ao_FieldDst.LineSlant = ao_FieldSrc.LineSlant
  
  
  Exit Sub
ErrHandler:
  Call ErrorHandler("CopyFieldProperties")
End Sub

Public Property Get SerializedReprintString()
On Error GoTo ErrHandler
Const C_EXCEPTIONS As String = "®COF_ID®Cap_F_OfferDetail.S_DESC®Cap_F_OfferDetail.COFD_PRIOF®Cap_F_OfferDetail.COFD_QTY1®Cap_F_OfferDetail.UM_CODE1®Cap_F_OfferDetail.PRIAPREXDA®Cap_F_OfferDetail.COFD_COMME®"
    Dim ll_Row  As Long
    Dim ll_cur  As Long
    Dim ll_fld  As Long
    Dim ls_ret  As String
    
    ls_ret = ""
    For ll_cur = 0 To UBound(mo_cursorData)
        For ll_fld = 0 To UBound(mo_cursorData(ll_cur).HEADERS)
            If InStr(1, C_EXCEPTIONS, SEP1 & mo_cursorData(ll_cur).HEADERS(ll_fld) & SEP1, vbTextCompare) = 0 Then
                ls_ret = ls_ret & IIf(ls_ret = "", "", SEP) & mo_cursorData(ll_cur).HEADERS(ll_fld)
                For ll_Row = 0 To UBound(mo_cursorData(ll_cur).Rows)
                    Debug.Assert (UBound(mo_cursorData(ll_cur).HEADERS) = UBound(mo_cursorData(ll_cur).Rows(ll_Row)))
                    ls_ret = ls_ret & IIf(ll_Row = 0, SEP1, SEP2) & mo_cursorData(ll_cur).Rows(ll_Row)(ll_fld)
                Next ll_Row
            End If
        Next ll_fld
    Next ll_cur
    
    If ms_ExternalSepString <> "" Then
        ls_ret = ls_ret & IIf(ls_ret = "", "", SEP) & ms_ExternalSepString
    End If
    
    SerializedReprintString = ls_ret
    Exit Property
ErrHandler:
    Call ErrorHandler("get SerializedReprintString")
End Property

Private Sub btn_SaveAsPDF_Click()
On Error GoTo ErrHandler
Dim ls_PDF_FileName As String
Dim ls_Msg As String

  Call mo_Tools.LockScreen(UserControl.Parent, True)
  ls_PDF_FileName = SavePDFFileName()
  
  If Len(ls_PDF_FileName) > 0 Then
      If mo_FSO.FileExists(ls_PDF_FileName) Then
          On Error Resume Next
          Call mo_FSO.DeleteFile(ls_PDF_FileName)
          On Error GoTo ErrHandler
          If mo_FSO.FileExists(ls_PDF_FileName) Then
            
            ls_Msg = mo_Tools.MsgText(mo_Db, ms_Language_Code, ArmCusErr.UnableDeleteFile, "#PDF file already exists and cannot be deleted.")
            Call MsgBox(ls_Msg, vbOKOnly, App.Title & " " & App.Major & "." & App.Minor & "." & App.Revision)
            
            Call mo_Tools.LockScreen(UserControl.Parent, False)
            
            Exit Sub
          End If
      End If
              
      Call ExecuteReport(mo_ReportParams, True)
      Call Report.RenderToFile(ls_PDF_FileName, vsrPDF)
  End If
  Call mo_Tools.LockScreen(UserControl.Parent, False)
  Exit Sub
ErrHandler:
  Call ErrorMessage("btn_SaveAsPDF_Click")
End Sub

' display standard error message
Public Sub ErrorMessage(ByVal as_Fct As String)
    Dim ls_ErrSource As String
    Dim ls_errDescription As String
    Dim ls_Message As String
    
    ls_ErrSource = as_Fct & SEP1 & Err.Source
    ls_errDescription = Err.Description
    ls_Message = SCREEN_NAME & " exception. Nr:" & Err.Number & ",Desc: " & ls_errDescription & ",Src:" & ls_ErrSource & "@"
    Call mo_Tools.LogMessage(mo_Db, ml_U_Code, SCREEN_NAME, ls_Message, "E")
    Call MsgBox("Error occured, please contact IT. Application will now shutdown." & vbCrLf & ls_ErrSource & vbCrLf & "Description: " & ls_errDescription, vbCritical, App.Title & " " & App.Major & "." & App.Minor & "." & App.Revision)
    End
End Sub

' Standard error handler
Private Sub ErrorHandler(ByVal as_Fct As String)
  
    Call Err.Raise(Err.Number, Extender.Name & "." & as_Fct & SEP1 & Err.Source, Err.Description)
End Sub

