VERSION 5.00
Begin VB.Form Query 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Query maker"
   ClientHeight    =   6870
   ClientLeft      =   180
   ClientTop       =   360
   ClientWidth     =   9210
   ClipControls    =   0   'False
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   6870
   ScaleWidth      =   9210
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton cmd_Date 
      Height          =   276
      Left            =   8220
      Style           =   1  'Graphical
      TabIndex        =   85
      Top             =   1620
      Visible         =   0   'False
      Width           =   252
   End
   Begin VB.PictureBox pic_Pic2 
      Appearance      =   0  'Flat
      AutoRedraw      =   -1  'True
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C0C0C0&
      Height          =   1332
      Left            =   8520
      ScaleHeight     =   1305
      ScaleWidth      =   585
      TabIndex        =   91
      Top             =   1140
      Width           =   612
      Begin VB.PictureBox pic_cancel 
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         Height          =   465
         Left            =   60
         ScaleHeight     =   465
         ScaleWidth      =   465
         TabIndex        =   93
         Top             =   600
         Width           =   465
      End
      Begin VB.PictureBox pic_ok 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         ForeColor       =   &H80000008&
         Height          =   465
         Left            =   60
         ScaleHeight     =   465
         ScaleWidth      =   465
         TabIndex        =   92
         Top             =   60
         Width           =   465
      End
   End
   Begin VB.PictureBox pic_Field 
      BackColor       =   &H00C0C0C0&
      BorderStyle     =   0  'None
      Height          =   375
      Left            =   2160
      ScaleHeight     =   375
      ScaleWidth      =   315
      TabIndex        =   94
      Top             =   1620
      Width           =   315
   End
   Begin VB.PictureBox pic_bureau 
      AutoRedraw      =   -1  'True
      BackColor       =   &H00FFFFFF&
      Height          =   4305
      Left            =   60
      ScaleHeight     =   4245
      ScaleWidth      =   8985
      TabIndex        =   4
      Top             =   2520
      Width           =   9045
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   50
         Left            =   8255
         TabIndex        =   64
         Top             =   120
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   51
         Left            =   8255
         TabIndex        =   63
         Top             =   520
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   52
         Left            =   8255
         TabIndex        =   62
         Top             =   920
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   53
         Left            =   8255
         TabIndex        =   61
         Top             =   1320
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   54
         Left            =   8255
         TabIndex        =   60
         Top             =   1720
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   55
         Left            =   8255
         TabIndex        =   59
         Top             =   2120
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   56
         Left            =   8255
         TabIndex        =   58
         Top             =   2520
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   57
         Left            =   8255
         TabIndex        =   57
         Top             =   2920
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   58
         Left            =   8255
         TabIndex        =   56
         Top             =   3320
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   59
         Left            =   8255
         TabIndex        =   55
         Top             =   3720
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   40
         Left            =   6950
         TabIndex        =   54
         Top             =   120
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   41
         Left            =   6950
         TabIndex        =   53
         Top             =   510
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   42
         Left            =   6950
         TabIndex        =   52
         Top             =   920
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   43
         Left            =   6950
         TabIndex        =   51
         Top             =   1320
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   44
         Left            =   6950
         TabIndex        =   50
         Top             =   1720
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   45
         Left            =   6950
         TabIndex        =   49
         Top             =   2120
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   46
         Left            =   6950
         TabIndex        =   48
         Top             =   2520
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   47
         Left            =   6950
         TabIndex        =   47
         Top             =   2920
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   48
         Left            =   6950
         TabIndex        =   46
         Top             =   3320
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   49
         Left            =   6950
         TabIndex        =   45
         Top             =   3720
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   30
         Left            =   5645
         TabIndex        =   44
         Top             =   120
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   31
         Left            =   5645
         TabIndex        =   43
         Top             =   520
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   32
         Left            =   5645
         TabIndex        =   42
         Top             =   920
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   33
         Left            =   5645
         TabIndex        =   41
         Top             =   1320
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   34
         Left            =   5645
         TabIndex        =   40
         Top             =   1720
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   35
         Left            =   5645
         TabIndex        =   39
         Top             =   2120
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   36
         Left            =   5645
         TabIndex        =   38
         Top             =   2520
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   37
         Left            =   5645
         TabIndex        =   37
         Top             =   2920
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   38
         Left            =   5645
         TabIndex        =   36
         Top             =   3320
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   39
         Left            =   5645
         TabIndex        =   35
         Top             =   3720
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   20
         Left            =   4355
         TabIndex        =   34
         Top             =   120
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   21
         Left            =   4355
         TabIndex        =   33
         Top             =   520
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   22
         Left            =   4355
         TabIndex        =   32
         Top             =   920
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   23
         Left            =   4355
         TabIndex        =   31
         Top             =   1320
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   24
         Left            =   4355
         TabIndex        =   30
         Top             =   1720
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   25
         Left            =   4355
         TabIndex        =   29
         Top             =   2120
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   26
         Left            =   4355
         TabIndex        =   28
         Top             =   2520
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   27
         Left            =   4355
         TabIndex        =   27
         Top             =   2920
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   28
         Left            =   4355
         TabIndex        =   26
         Top             =   3320
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   29
         Left            =   4355
         TabIndex        =   25
         Top             =   3720
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   19
         Left            =   3050
         TabIndex        =   24
         Top             =   3720
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   18
         Left            =   3050
         TabIndex        =   23
         Top             =   3320
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   17
         Left            =   3050
         TabIndex        =   22
         Top             =   2920
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   16
         Left            =   3050
         TabIndex        =   21
         Top             =   2520
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   15
         Left            =   3050
         TabIndex        =   20
         Top             =   2120
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   14
         Left            =   3050
         TabIndex        =   19
         Top             =   1720
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   13
         Left            =   3050
         TabIndex        =   18
         Top             =   1320
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   12
         Left            =   3050
         TabIndex        =   17
         Top             =   920
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   225
         Index           =   11
         Left            =   3050
         TabIndex        =   16
         Top             =   520
         Width           =   465
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   228
         Index           =   10
         Left            =   3000
         TabIndex        =   15
         Top             =   180
         Width           =   468
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   390
         Index           =   0
         Left            =   45
         TabIndex        =   14
         Top             =   315
         Width           =   2585
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   390
         Index           =   1
         Left            =   45
         TabIndex        =   13
         Top             =   720
         Width           =   2585
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   390
         Index           =   2
         Left            =   45
         TabIndex        =   12
         Top             =   1125
         Width           =   2585
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   390
         Index           =   3
         Left            =   45
         TabIndex        =   11
         Top             =   1520
         Width           =   2585
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   390
         Index           =   4
         Left            =   45
         TabIndex        =   10
         Top             =   1920
         Width           =   2585
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   390
         Index           =   5
         Left            =   45
         TabIndex        =   9
         Top             =   2320
         Width           =   2585
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   390
         Index           =   6
         Left            =   45
         TabIndex        =   8
         Top             =   2720
         Width           =   2585
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   390
         Index           =   7
         Left            =   45
         TabIndex        =   7
         Top             =   3120
         Width           =   2585
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   390
         Index           =   8
         Left            =   45
         TabIndex        =   6
         Top             =   3520
         Width           =   2585
      End
      Begin VB.Label lbl_Bureau 
         BackStyle       =   0  'Transparent
         Height          =   390
         Index           =   9
         Left            =   45
         TabIndex        =   5
         Top             =   3920
         Width           =   2585
      End
   End
   Begin VB.ComboBox cbo_value 
      Height          =   315
      ItemData        =   "QUERY.frx":0000
      Left            =   5580
      List            =   "QUERY.frx":0002
      Style           =   2  'Dropdown List
      TabIndex        =   1
      Top             =   1620
      Visible         =   0   'False
      Width           =   2892
   End
   Begin VB.PictureBox pic_Symbol 
      Appearance      =   0  'Flat
      AutoRedraw      =   -1  'True
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000008&
      Height          =   612
      Left            =   2520
      ScaleHeight     =   585
      ScaleWidth      =   2985
      TabIndex        =   67
      Top             =   1440
      Visible         =   0   'False
      Width           =   3012
      Begin VB.PictureBox pic_inf 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         ForeColor       =   &H80000008&
         Height          =   444
         Left            =   60
         ScaleHeight     =   450
         ScaleWidth      =   450
         TabIndex        =   81
         Top             =   60
         Width           =   444
      End
      Begin VB.PictureBox pic_diff 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         ForeColor       =   &H80000008&
         Height          =   444
         Left            =   1020
         ScaleHeight     =   450
         ScaleWidth      =   450
         TabIndex        =   78
         Top             =   60
         Width           =   444
      End
      Begin VB.PictureBox pic_sup 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         ForeColor       =   &H80000008&
         Height          =   444
         Left            =   2460
         ScaleHeight     =   450
         ScaleWidth      =   450
         TabIndex        =   77
         Top             =   60
         Width           =   444
      End
      Begin VB.PictureBox pic_sup_egal 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         ForeColor       =   &H80000008&
         Height          =   444
         Left            =   1980
         ScaleHeight     =   450
         ScaleWidth      =   450
         TabIndex        =   76
         Top             =   60
         Width           =   444
      End
      Begin VB.PictureBox pic_egal 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         ForeColor       =   &H80000008&
         Height          =   444
         Left            =   1500
         ScaleHeight     =   450
         ScaleWidth      =   450
         TabIndex        =   75
         Top             =   60
         Width           =   444
      End
      Begin VB.PictureBox pic_inf_egal 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         ForeColor       =   &H80000008&
         Height          =   444
         Left            =   540
         ScaleHeight     =   450
         ScaleWidth      =   450
         TabIndex        =   80
         Top             =   60
         Width           =   444
      End
      Begin VB.PictureBox pic_like 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         ForeColor       =   &H80000008&
         Height          =   444
         Left            =   540
         ScaleHeight     =   450
         ScaleWidth      =   450
         TabIndex        =   79
         Top             =   60
         Width           =   444
      End
   End
   Begin VB.TextBox txt_value 
      Height          =   288
      Left            =   5580
      TabIndex        =   3
      Top             =   1620
      Visible         =   0   'False
      Width           =   2652
   End
   Begin VB.ComboBox cbo_field 
      Enabled         =   0   'False
      Height          =   288
      ItemData        =   "QUERY.frx":0004
      Left            =   60
      List            =   "QUERY.frx":0006
      Style           =   2  'Dropdown List
      TabIndex        =   66
      TabStop         =   0   'False
      Top             =   1620
      Width           =   2352
   End
   Begin VB.Frame frm_Filter 
      Caption         =   "Item filter"
      Height          =   552
      Left            =   0
      TabIndex        =   95
      Top             =   660
      Width           =   8472
      Begin VB.ComboBox cbo_CategoryCode 
         Height          =   288
         ItemData        =   "QUERY.frx":0008
         Left            =   3360
         List            =   "QUERY.frx":000A
         Style           =   2  'Dropdown List
         TabIndex        =   101
         Top             =   180
         Visible         =   0   'False
         Width           =   312
      End
      Begin VB.ComboBox cbo_Category 
         Height          =   288
         ItemData        =   "QUERY.frx":000C
         Left            =   1560
         List            =   "QUERY.frx":000E
         Style           =   2  'Dropdown List
         TabIndex        =   99
         Top             =   180
         Width           =   2352
      End
      Begin VB.OptionButton opt_All 
         Caption         =   "All"
         Height          =   312
         Left            =   4500
         TabIndex        =   98
         Top             =   180
         Width           =   792
      End
      Begin VB.OptionButton opt_Dropped 
         Caption         =   "Dropped"
         Height          =   312
         Left            =   5400
         TabIndex        =   97
         Top             =   180
         Width           =   1392
      End
      Begin VB.OptionButton opt_NonDropped 
         Caption         =   "Non dropped"
         Height          =   312
         Left            =   6780
         TabIndex        =   96
         Top             =   180
         Value           =   -1  'True
         Width           =   1572
      End
      Begin VB.Label lbl_Category 
         Caption         =   "Category"
         Height          =   228
         Left            =   60
         TabIndex        =   100
         Top             =   240
         Width           =   1512
      End
   End
   Begin VB.PictureBox pic_Pic 
      Appearance      =   0  'Flat
      AutoRedraw      =   -1  'True
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C0C0C0&
      Height          =   612
      Left            =   0
      ScaleHeight     =   585
      ScaleWidth      =   9165
      TabIndex        =   65
      Top             =   0
      Width           =   9192
      Begin VB.PictureBox pic_Load 
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         Height          =   465
         Left            =   720
         ScaleHeight     =   465
         ScaleWidth      =   465
         TabIndex        =   84
         Top             =   60
         Width           =   465
      End
      Begin VB.PictureBox pic_Save 
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         Height          =   465
         Left            =   1320
         ScaleHeight     =   465
         ScaleWidth      =   465
         TabIndex        =   83
         Top             =   60
         Width           =   465
      End
      Begin VB.PictureBox pic_Upd 
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         Height          =   465
         Left            =   4380
         ScaleHeight     =   465
         ScaleWidth      =   465
         TabIndex        =   82
         Top             =   60
         Visible         =   0   'False
         Width           =   465
      End
      Begin VB.PictureBox pic_new 
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         Height          =   465
         Left            =   60
         ScaleHeight     =   465
         ScaleWidth      =   465
         TabIndex        =   74
         Top             =   60
         Width           =   465
      End
      Begin VB.PictureBox pic_or 
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         Height          =   465
         Left            =   3360
         ScaleHeight     =   465
         ScaleWidth      =   465
         TabIndex        =   73
         Top             =   60
         Width           =   465
      End
      Begin VB.PictureBox pic_exec 
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         Height          =   465
         Left            =   6060
         ScaleHeight     =   465
         ScaleWidth      =   465
         TabIndex        =   72
         Top             =   60
         Width           =   465
      End
      Begin VB.PictureBox pic_delete 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         ForeColor       =   &H80000008&
         Height          =   465
         Left            =   4980
         ScaleHeight     =   465
         ScaleWidth      =   465
         TabIndex        =   71
         Top             =   60
         Width           =   465
      End
      Begin VB.PictureBox pic_and 
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         Height          =   465
         Left            =   2760
         ScaleHeight     =   465
         ScaleWidth      =   465
         TabIndex        =   70
         Top             =   60
         Width           =   465
      End
      Begin VB.PictureBox pic_quit 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DragIcon        =   "QUERY.frx":0010
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   465
         Left            =   7380
         ScaleHeight     =   465
         ScaleWidth      =   465
         TabIndex        =   68
         Top             =   60
         Width           =   465
      End
   End
   Begin VB.Label lbl_Start 
      Caption         =   "Show details"
      Height          =   228
      Left            =   9660
      TabIndex        =   90
      Top             =   780
      Visible         =   0   'False
      Width           =   732
   End
   Begin VB.Label lbl_Detail 
      Caption         =   "Details :"
      Height          =   228
      Left            =   9240
      TabIndex        =   88
      Top             =   780
      Visible         =   0   'False
      Width           =   732
   End
   Begin VB.Label lbl_Result2 
      Caption         =   "found"
      Height          =   228
      Left            =   9000
      TabIndex        =   87
      Top             =   780
      Visible         =   0   'False
      Width           =   732
   End
   Begin VB.Label lbl_Result 
      Caption         =   "Result :"
      Height          =   228
      Left            =   8760
      TabIndex        =   86
      Top             =   780
      Visible         =   0   'False
      Width           =   732
   End
   Begin VB.Label lbl_Title 
      Caption         =   "Results"
      Height          =   228
      Left            =   8520
      TabIndex        =   89
      Top             =   780
      Visible         =   0   'False
      Width           =   732
   End
   Begin VB.Label lbl_value 
      Alignment       =   2  'Center
      Caption         =   "Value"
      Height          =   228
      Left            =   5580
      TabIndex        =   69
      Top             =   1380
      Width           =   2892
   End
   Begin VB.Label lbl_info 
      BackColor       =   &H00808000&
      BorderStyle     =   1  'Fixed Single
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      Height          =   312
      Left            =   -60
      TabIndex        =   2
      Top             =   2160
      Width           =   8532
   End
   Begin VB.Label lbl_field 
      Alignment       =   2  'Center
      Caption         =   "Criteria"
      Height          =   228
      Left            =   60
      TabIndex        =   0
      Top             =   1380
      Width           =   2352
   End
End
Attribute VB_Name = "Query"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim ms_Sign As String ' symbol of comparasion for query
Dim ms_DisplaySign As String ' symbol of comparasion for display
Dim mb_AddDeskLine As Boolean ' True = Create a new line, False = update existing line
Dim mi_NbSelLabels As Integer ' number of selected labels
Dim mi_FFLine As Integer ' number of the first free line of the frst column
Dim mb_FColStatus(9) As Boolean ' indicate the state of the labels of the first column (free or not)
Dim mb_SelectLabel(5, 9) As Boolean ' list of selected labels
Dim mb_UsedLabel(5, 9) As Boolean ' list of used labels
Dim ms_QueryArray(5, 9, 6) As String ' needed to determinate the query
Dim ms_TransValue As String ' translation for "Value :"
Dim ms_TransOr As String ' translation for "Or"
Dim ms_TransAnd As String ' translation for "And"
Dim ms_TransDate As String ' translation for "mmddyyyy"
Dim ms_TransGeneral As String ' translation for general
Dim ms_TransLike As String ' translation for LIKE
Dim ms_Ceiling  As String 'Ceiling code
Dim ms_Grid  As String 'Grid code
Dim mb_WorkingFiles As Boolean 'WorkingFiles already exists
Dim ml_PlantStmt As Long 'statement for Plant working file
Dim ml_ClaimStmt As Long 'statement for Claim working file
Dim ml_TerritoryStmt As Long 'statement for Territory working file
Private Sub W_Territory()
Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim li_Index As Integer

ls_Req = "Select TER.TER_Code INTO #W_Territory " _
  & " FROM Sales_Market SMK,Claim_Coordinator CCO,Claim_Security_Alias CSA, Claim_Coordinator_Link CCOL,Sales_Office SO, Sales_Office_Link SOL, Territories TER, Countries CT, Countries_Sales_Markets CSMK " _
  & "WHERE CSA_login = '" & prg.LoginName & "' AND CSA_Function = 'COORD' " & " AND CCO.CCO_code = CSA_Code AND CCO.Language_code = 'E' AND CCOL.CCO_Code = CCO.CCO_Code AND CCOL.SO_Code = SO.SO_Code " & " AND SO.Language_code = 'E' AND SOL.SO_Code = SO.SO_Code AND SMK.SMK_Code = SOL.SMK_Code AND SMK.Language_code = 'E' AND CSMK.SMK_code = SMK.SMK_code AND CSMK.CT_Code = CT.CT_Code AND CT.Language_code = 'E'" _
  & " AND CT.CT_Code = TER.CT_code AND TER.Language_code = 'E' " _
  & " UNION Select TER.TER_Code FROM Sales_Market SMK,Claim_Security_Alias CSA,Claim_Security CSE, Sales_Office SO, Sales_Office_Link SOL, Territories TER, Countries CT, Countries_Sales_Markets CSMK " _
  & " WHERE CSA_login = '" & prg.LoginName & "' AND CSA_Function = 'COORD' AND CSA.CSA_code = CSE.CSA_Code AND CSE.CSE_Code = SO.SO_Code AND SO.Language_code = 'E' AND SOL.SO_Code = SO.SO_Code " _
  & " AND SMK.SMK_Code = SOL.SMK_Code AND SMK.Language_code = 'E' AND CSMK.SMK_code = SMK.SMK_code AND CSMK.CT_Code = CT.CT_Code AND CT.Language_code = 'E' AND CT.CT_Code = TER.CT_code AND TER.Language_code = 'E'" _
  & "AND CSE.CSE_Function = 'COORD' "
If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
    ml_TerritoryStmt = ll_Statement
    li_Status = SQL_SUCCESS
Else
    li_Status = SQL_ERROR
End If

li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
End Sub
Private Sub W_Plant()
Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim li_Index As Integer

ls_Req = "Select MFGP.MFGP_Code INTO #W_Plant " _
    & " FROM Plants MFGP,Claim_Contact CPC,Claim_Security_Alias CSA " _
    & "WHERE CSA_login = '" & prg.LoginName & "' AND CSA_Function = 'Contact' " _
    & "AND CPC_code = CSA_Code AND CPC.Language_code = 'E' " _
    & "AND MFGP.MFGP_Code = CPC.MFGP_Code AND MFGP.Language_code = 'E'"
    
If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
    ml_PlantStmt = ll_Statement
    li_Status = SQL_SUCCESS
Else
    li_Status = SQL_ERROR
End If

li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
End Sub
Private Function W_FileDrop(ls_WFile As String, ll_Stmt As Long) As Boolean

Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim li_Order As Integer
Dim ls_Text As String

On Error GoTo ErrTM99011a

ls_Req = "DROP TABLE #W_" & ls_WFile
If SQLSubmit(gl_Environment, gl_Database, ll_Stmt, ls_Req) Then
    li_Status = SQL_SUCCESS
Else
    li_Status = SQL_ERROR
End If
li_Status = SQLFreeStatement(ll_Stmt, SQL_DROP)
Exit Function

ErrTM99011a:
li_Status = SQLFreeStatement(ll_Stmt, SQL_DROP)
StdError
End Function
Private Sub W_Claim()
Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim li_Index As Integer

mb_WorkingFiles = KO
ls_Req = "SELECT  C.CLA_code " _
 & "INTO #W_Claim FROM Claim C, Claim_Plant CPL,#W_Plant W " _
 & " WHERE CPL.MFGP_Code = W.MFGP_Code AND CPL.Language_code = 'E' " _
 & " AND C.CLA_Code = CPL.CLA_Code AND C.Language_code = 'E' " _
 & " UNION SELECT C.CLA_code FROM Claim C, #W_Territory W " _
 & " WHERE C.TER_Code = W.TER_Code"
 
If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
    ml_ClaimStmt = ll_Statement
    mb_WorkingFiles = OK
    li_Status = SQL_SUCCESS
Else
    li_Status = SQL_ERROR
End If

li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
End Sub
Private Sub QuerySecurity()

Dim ll_Statement As Long
Dim ls_Req As String
Dim li_Status As Integer

gi_QuerySecurityLevel = 0
Select Case gut_Param.Str1
Case "Base_Item"
    ls_Req = "EXEC Query_Security_sel '" & prg.LoginName & "','Query for item'"
Case "Claim"
    ls_Req = "EXEC Query_Security_sel '" & prg.LoginName & "','Query for claim'"
Case "sa_historic"
    ls_Req = "EXEC Query_Security_sel '" & prg.LoginName & "','Query for sales'"
End Select
If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
    li_Status = SQLFetch(ll_Statement)
    If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
        gi_QuerySecurityLevel = ODBCData(ll_Statement, 1)
    End If
End If

End Sub
Private Sub InitDesk()
' Clear or/and Initialize each Control, Data or Table
' When the form is loaded or when "blank page" button is selected
Dim i As Integer, j As Integer

mi_FFLine = 0
For i = 0 To 59
    lbl_Bureau(i) = ""
    gs_QueryIO(i) = ""
Next i
For i = 0 To 9
    mb_FColStatus(i) = OK
    For j = 0 To 5
        mb_UsedLabel(j, i) = KO
        ms_QueryArray(j, i, 0) = ""
        ms_QueryArray(j, i, 1) = ""
        ms_QueryArray(j, i, 2) = ""
        ms_QueryArray(j, i, 3) = ""
        ms_QueryArray(j, i, 4) = ""
        ms_QueryArray(j, i, 5) = ""
        ms_QueryArray(j, i, 6) = ""
    Next j
Next i
pic_bureau.Cls
InitObjects
DeselectOp

End Sub
Private Sub DisplayDeskButtons()
' Determinate which buttons to show
Dim i As Integer, j As Integer
Dim lb_ShowOrAnd As Boolean
Dim lb_AllowDel As Boolean ' indicate if the "delete" picture can be displayed
Dim lb_AtLeastOneSel As Boolean
Dim lb_ExistingHole As Boolean
Dim lb_ShowUpd As Boolean
Dim ls_LastSelItem As String

lb_ShowOrAnd = OK
lb_AllowDel = OK
For i = 0 To 9
    For j = 0 To 5
        If mb_UsedLabel(j, i) And mb_SelectLabel(j, i) Then
'       One selected item is already used : it can't be part of a new condition
'       This item is used so we can't delete it
            lb_ShowOrAnd = KO
            lb_AllowDel = KO
        End If
        If mb_SelectLabel(j, i) Then
            ls_LastSelItem = ms_QueryArray(j, i, 6)
            If j > 0 Then
'       A condition expression (j > 0) can't be deleted
                lb_AllowDel = KO
            End If
            If j = 5 Then
                lb_ShowOrAnd = KO
            End If
        End If
    Next j
Next i
lb_AtLeastOneSel = KO
lb_ExistingHole = KO
lb_ShowUpd = KO
For i = 0 To 9
    For j = 5 To 0 Step -1
        If mb_SelectLabel(j, i) Then
            lb_AtLeastOneSel = OK
        End If
        If ms_QueryArray(j, i, 6) <> "" And Not mb_UsedLabel(j, i) And Not mb_SelectLabel(j, i) And lb_AtLeastOneSel = OK Then
            lb_ExistingHole = OK
        End If
        If mb_SelectLabel(j, i) And lb_ExistingHole Then
            lb_ShowOrAnd = KO
        End If
        If ms_QueryArray(j, i, 6) = ls_LastSelItem And j = 0 Then
            lb_ShowUpd = OK
        End If
    Next j
Next i
Select Case mi_NbSelLabels
Case 0
    pic_delete.Visible = KO
    pic_upd.Visible = KO
    pic_or.Visible = KO
    pic_and.Visible = KO
Case 1
    If lb_AllowDel Then
        pic_delete.Visible = OK
    Else
        pic_delete.Visible = KO
    End If
    If lb_ShowUpd Then
        pic_upd.Visible = OK
    Else
        pic_upd.Visible = KO
    End If
    pic_or.Visible = KO
    pic_and.Visible = KO
Case Else
    If lb_AllowDel Then
        pic_delete.Visible = OK
    Else
        pic_delete.Visible = KO
    End If
    pic_upd.Visible = KO
    If lb_ShowOrAnd Then
        pic_or.Visible = OK
        pic_and.Visible = OK
    Else
        pic_or.Visible = KO
        pic_and.Visible = KO
    End If
End Select

End Sub
Private Sub UpdateLine()

Dim ls_Element As String
Dim ls_ElementQuery As String
Dim ls_OldString As String
Dim li_CurrentCriteria As Integer
Dim i As Integer, j As Integer, k As Integer

li_CurrentCriteria = cbo_field.ItemData(cbo_field.ListIndex)
ls_ElementQuery = gut_Field(li_CurrentCriteria).Criteria
If cbo_Value.Visible = OK Then
    ls_Element = cbo_field & ms_DisplaySign & "'" & cbo_Value & "'"
    ls_ElementQuery = ls_ElementQuery & ms_Sign & "'" & cbo_Value & "'"
Else
    Select Case gut_Field(li_CurrentCriteria).DataType
    Case "DATE"
        ls_Element = cbo_field & ms_DisplaySign & "'" & txt_value & "'"
        ls_ElementQuery = ls_ElementQuery & ms_Sign & "'" & FormatD(txt_value, "mm/dd/yyyy") & "'"
    Case "DATE2"
        ls_Element = cbo_field & ms_DisplaySign & "'" & txt_value & "'"
        ls_ElementQuery = ls_ElementQuery & ms_Sign & "'" & FormatD(txt_value, "yyyymmdd") & "'"
    Case "VARCHAR", "VARLIKE"
        ls_Element = cbo_field & ms_DisplaySign & "'" & txt_value & "'"
        ls_ElementQuery = ls_ElementQuery & ms_Sign & "'%" & txt_value & "%'"
    Case Else
'   figures
        ls_Element = cbo_field & ms_DisplaySign & txt_value
        ls_ElementQuery = ls_ElementQuery & ms_Sign & txt_value
    End Select
End If
For k = 0 To 9
    If lbl_Bureau(k).ForeColor = BLUE Then
        lbl_Bureau(k) = ls_Element
        ls_OldString = ms_QueryArray(0, k, 6)
        ms_QueryArray(0, k, 6) = ls_ElementQuery
        PrepareSave "OK", k, ls_ElementQuery
        Exit For
    End If
Next k
For i = 0 To 9
    For j = 1 To 5
        If ms_QueryArray(j, i, 6) <> "" Then
            ms_QueryArray(j, i, 6) = StringReplace(ms_QueryArray(j, i, 6), ls_OldString, ms_QueryArray(0, k, 6))
        End If
    Next j
Next i

End Sub
Private Sub FillGrids()
' Fill the Grid of the form with data contained
' in the Query_Param1 and Query_Param2 tables
' depending of the login Language
Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim li_Index As Integer
Dim lb_FirstDetail As Boolean
Dim lb_FirstSubDetail As Boolean
Dim lb_FirstField As Boolean
Dim ls_CurrDetail As String
Dim ls_CurrSubDetail As String

' = 1 because the trier function is sorting a grid with a header (row1)
ReDim gut_Field(0)
lb_FirstField = OK
ReDim gut_Detail(0)
lb_FirstDetail = OK
ls_CurrDetail = ""
ReDim gut_SubDetail(0)
lb_FirstSubDetail = OK
ls_CurrSubDetail = ""
If gut_Param.Str1 = "Test" Then
' change gut_Param.Str3 to text
    ls_Req = "EXEC Query_Grid_lst '" _
        & gut_Param.Str1 & "', '" _
        & gut_Param.Str2 & "', '" _
        & gut_Param.Str3 & "', " _
        & gi_QuerySecurityLevel & ", '" _
        & gut_LangLogin.Code & "'"
Else
ls_Req = "EXEC Query_Grid_lst '" _
    & gut_Param.Str1 & "', '" _
    & gut_Param.Str2 & "', " _
    & gut_Param.Str3 & ", " _
    & gi_QuerySecurityLevel & ", '" _
    & gut_LangLogin.Code & "'"
End If
If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
    li_Status = SQL_SUCCESS
Else
    li_Status = SQL_ERROR
End If
Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
    li_Status = SQLFetch(ll_Statement)
    If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
        If lb_FirstField Then
            lb_FirstField = KO
        Else
            ReDim Preserve gut_Field(UBound(gut_Field) + 1)
        End If
        li_Index = UBound(gut_Field)
        gut_Field(li_Index).Criteria = ODBCData(ll_Statement, 1)
        gut_Field(li_Index).Validity = ODBCData(ll_Statement, 2)
        gut_Field(li_Index).DataType = ODBCData(ll_Statement, 3)
        gut_Field(li_Index).trans = ODBCData(ll_Statement, 4)
        gut_Field(li_Index).FromClauseVal = Trim(ODBCMemoGet(ll_Statement, 5))
        gut_Field(li_Index).JoinClauseVal = Trim(ODBCMemoGet(ll_Statement, 6))
        gut_Field(li_Index).JoinClauseVal = ReplaceInString(gut_Field(li_Index).JoinClauseVal, "##REST", gut_Param.Str3)
        gut_Field(li_Index).JoinClauseVal = ReplaceInString(gut_Field(li_Index).JoinClauseVal, "##LANG", "'" & gut_LangLogin.Code & "'")
        gut_Field(li_Index).FromClauseRes = Trim(ODBCMemoGet(ll_Statement, 7))
        gut_Field(li_Index).JoinClauseRes = Trim(ODBCMemoGet(ll_Statement, 8))
        gut_Field(li_Index).JoinClauseRes = ReplaceInString(gut_Field(li_Index).JoinClauseRes, "##REST", gut_Param.Str3)
        gut_Field(li_Index).JoinClauseRes = ReplaceInString(gut_Field(li_Index).JoinClauseRes, "##LANG", "'" & gut_LangLogin.Code & "'")
        gut_Field(li_Index).FromClauseExist = Trim(ODBCMemoGet(ll_Statement, 9))
        gut_Field(li_Index).FromClauseExist2 = Trim(ODBCMemoGet(ll_Statement, 10))
        gut_Field(li_Index).JoinClauseExist = Trim(ODBCMemoGet(ll_Statement, 11))
        gut_Field(li_Index).JoinClauseExist = ReplaceInString(gut_Field(li_Index).JoinClauseExist, "##REST", gut_Param.Str3)
        gut_Field(li_Index).JoinClauseExist = ReplaceInString(gut_Field(li_Index).JoinClauseExist, "##LANG", "'" & gut_LangLogin.Code & "'")
        gut_Field(li_Index).JoinClauseExist2 = Trim(ODBCMemoGet(ll_Statement, 12))
        gut_Field(li_Index).JoinClauseExist2 = ReplaceInString(gut_Field(li_Index).JoinClauseExist2, "##REST", gut_Param.Str3)
        gut_Field(li_Index).JoinClauseExist2 = ReplaceInString(gut_Field(li_Index).JoinClauseExist2, "##LANG", "'" & gut_LangLogin.Code & "'")
        gut_Field(li_Index).Detail = ODBCData(ll_Statement, 13)
        gut_Field(li_Index).SubDetail = ODBCData(ll_Statement, 14)
        gut_Field(li_Index).DetailTrans = ODBCData(ll_Statement, 15)
        If gut_Field(li_Index).Detail <> ls_CurrDetail Then
'       Detail change
            ls_CurrDetail = gut_Field(li_Index).Detail
            ls_CurrSubDetail = ""
            If lb_FirstDetail Then
                lb_FirstDetail = KO
            Else
                ReDim Preserve gut_Detail(UBound(gut_Detail) + 1)
            End If
            gut_Detail(UBound(gut_Detail)).DetailTrans = gut_Field(li_Index).DetailTrans
            gut_Detail(UBound(gut_Detail)).Detail = ls_CurrDetail
        End If
        If gut_Field(li_Index).SubDetail <> ls_CurrSubDetail Then
'       Sub detail change
            ls_CurrSubDetail = gut_Field(li_Index).SubDetail
            If lb_FirstSubDetail Then
                lb_FirstSubDetail = KO
            Else
                ReDim Preserve gut_SubDetail(UBound(gut_SubDetail) + 1)
            End If
            gut_SubDetail(UBound(gut_SubDetail)).Detail = ls_CurrDetail
            gut_SubDetail(UBound(gut_SubDetail)).SubDetail = ls_CurrSubDetail
        End If
    End If
Loop
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
FillCboField

End Sub
Private Sub FillValue()
' Determinate which Control to show
' and fill , if necessary, the ComboBoxes "cbo_value"  and "cbo_code"
' with the contains of the columns "description" and "code"
' of the corresponding table by accessing to the server
Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer

pic_ok.Visible = KO
lbl_Value.Visible = OK
lbl_Value = ms_TransValue
Select Case gut_Field(cbo_field.ItemData(cbo_field.ListIndex)).DataType
Case "INTEGER", "NUMERIC"
    txt_value.Locked = KO
    txt_value.Visible = OK
    txt_value = ""
    txt_value.SetFocus
    cmd_Date.Visible = KO
    cbo_Value.Visible = KO
Case "DATE", "DATE2"
    lbl_Value = lbl_Value & ms_TransDate
    txt_value.Locked = OK
    txt_value.Visible = OK
    txt_value = ""
    txt_value.SetFocus
    cmd_Date.Visible = OK
    cbo_Value.Visible = KO
Case "VARLIKE"
    txt_value.Locked = KO
    txt_value.Visible = OK
    txt_value = ""
    txt_value.SetFocus
    cmd_Date.Visible = KO
    cbo_Value.Visible = KO
Case "VARCHAR"
    Select Case ms_Sign
    Case " LIKE "
        txt_value.Locked = KO
        txt_value.Visible = OK
        txt_value = ""
        txt_value.SetFocus
        cmd_Date.Visible = KO
        cbo_Value.Visible = KO
    Case Else
        If Not cbo_Value.Visible Then
            txt_value.Visible = KO
            cmd_Date.Visible = KO
            cbo_Value.Visible = OK
            cbo_Value.Clear
            ls_Req = "SELECT DISTINCT " & gut_Field(cbo_field.ItemData(cbo_field.ListIndex)).Criteria _
                & " FROM " & gut_Field(cbo_field.ItemData(cbo_field.ListIndex)).FromClauseVal
            If gut_Field(cbo_field.ItemData(cbo_field.ListIndex)).JoinClauseVal <> "" Then
                ls_Req = ls_Req & " WHERE " & gut_Field(cbo_field.ItemData(cbo_field.ListIndex)).JoinClauseVal
            End If
            ls_Req = ls_Req & " ORDER BY " & gut_Field(cbo_field.ItemData(cbo_field.ListIndex)).Criteria
'Apply claim security to plant & market combos
            If UCase(gut_Param.Str1) = "CLAIM" And UCase(cbo_field.Text) = "PLANT" Then
                ls_Req = "EXEC plants_cbo3 '" & gut_Param.Str5 & "' "
            End If
            If UCase(gut_Param.Str1) = "CLAIM" And UCase(cbo_field.Text) = "SALES MARKET" Then
                ls_Req = "EXEC sales_market_cbo4 '" & gut_Param.Str5 & "' "
            End If
            If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
                li_Status = SQL_SUCCESS
            Else
                li_Status = SQL_ERROR
            End If
            Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
                li_Status = SQLFetch(ll_Statement)
                If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
                    cbo_Value.AddItem ODBCData(ll_Statement, 1)
                End If
            Loop
            li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        End If
        cbo_Value.ListIndex = -1
        cbo_Value.SetFocus
    End Select
End Select

End Sub
Private Sub FillCboField()
' Fill the ComboBox cbo_field with all the criteria in the grid
Dim i As Integer

cbo_field.Clear
For i = 0 To UBound(gut_Field)
    If gut_Field(i).Validity = "1" Then
        cbo_field.AddItem gut_Field(i).trans
        cbo_field.ItemData(cbo_field.ListCount - 1) = i
    End If
Next i
cbo_field.ListIndex = -1

End Sub
Private Sub CreateLine()
' Create a new item on the desk with all associated arrays
Dim ls_Element As String
Dim ls_ElementQuery As String
Dim li_CurrentCriteria As Integer

li_CurrentCriteria = cbo_field.ItemData(cbo_field.ListIndex)
ls_ElementQuery = gut_Field(li_CurrentCriteria).Criteria
If cbo_Value.Visible = OK Then
' The combo is used for value entry
    ls_Element = cbo_field & ms_DisplaySign & "'" & cbo_Value & "'"
    ls_ElementQuery = ls_ElementQuery & ms_Sign & "'" & cbo_Value & "'"
Else
    Select Case gut_Field(li_CurrentCriteria).DataType
    Case "DATE"
        ls_Element = cbo_field & ms_DisplaySign & "'" & txt_value & "'"
        ls_ElementQuery = ls_ElementQuery & ms_Sign & "'" & FormatD(txt_value, "mm/dd/yyyy") & "'"
    Case "DATE2"
        ls_Element = cbo_field & ms_DisplaySign & "'" & txt_value & "'"
        ls_ElementQuery = ls_ElementQuery & ms_Sign & "'" & FormatD(txt_value, "yyyymmdd") & "'"
    Case "VARCHAR", "VARLIKE"
        ls_Element = cbo_field & ms_DisplaySign & "'" & txt_value & "'"
        ls_ElementQuery = ls_ElementQuery & ms_Sign & "'%" & QuoteParam(txt_value) & "%'"
    Case Else
'   figures
        ls_Element = cbo_field & ms_DisplaySign & txt_value
        ls_ElementQuery = ls_ElementQuery & ms_Sign & txt_value
    End Select
End If
mb_FColStatus(mi_FFLine) = KO
lbl_Bureau(mi_FFLine) = ls_Element
ms_QueryArray(0, mi_FFLine, 0) = gut_Field(li_CurrentCriteria).FromClauseRes
ms_QueryArray(0, mi_FFLine, 1) = gut_Field(li_CurrentCriteria).JoinClauseRes
ms_QueryArray(0, mi_FFLine, 2) = gut_Field(li_CurrentCriteria).FromClauseExist
ms_QueryArray(0, mi_FFLine, 3) = gut_Field(li_CurrentCriteria).FromClauseExist2
ms_QueryArray(0, mi_FFLine, 4) = gut_Field(li_CurrentCriteria).JoinClauseExist
ms_QueryArray(0, mi_FFLine, 5) = gut_Field(li_CurrentCriteria).JoinClauseExist2
ms_QueryArray(0, mi_FFLine, 6) = ls_ElementQuery
PrepareSave "OK", mi_FFLine, ls_ElementQuery

End Sub
Private Sub RestoreQuery()

Dim i As Integer, j As Integer, k As Integer
Dim li_SpacePos1 As Integer, li_SpacePos2 As Integer
Dim ls_Criteria As String
Dim ls_Symbol As String
Dim ls_Value As String
Dim li_Count As Integer
Dim ls_Trans As String
Dim ls_DisplayText As String
Dim ls_QueryText As String
Dim ls_Operator As String
Dim ls_Date As String
Dim li_XYDesk As Integer, li_XDesk As Integer, li_YDesk As Integer
Dim ls_SelFields As String

For i = 0 To 9
    If gs_QueryIO(i) <> "" Then
'   extract parameters from the saved string
        li_SpacePos1 = InStr(1, gs_QueryIO(i), " ")
        li_SpacePos2 = InStr(li_SpacePos1 + 1, gs_QueryIO(i), " ")
        ls_Criteria = Left(gs_QueryIO(i), li_SpacePos1 - 1)
        ls_Symbol = Mid(gs_QueryIO(i), li_SpacePos1 + 1, li_SpacePos2 - li_SpacePos1 - 1)
        ls_Value = right(gs_QueryIO(i), Len(gs_QueryIO(i)) - li_SpacePos2)
        li_Count = 0
        While gut_Field(li_Count).Criteria <> ls_Criteria
            If li_Count < UBound(gut_Field) Then
                li_Count = li_Count + 1
            Else
                InitDesk
                Exit Sub
            End If
        Wend
        ls_Trans = gut_Field(li_Count).trans
        Select Case gut_Field(li_Count).DataType
        Case "INTEGER"
            ls_DisplayText = ls_Trans & " " & ls_Symbol & " " & Val(ls_Value)
            ls_QueryText = ls_Criteria & " " & ls_Symbol & " " & Val(ls_Value)
        Case "NUMERIC"
            ls_DisplayText = ls_Trans & " " & ls_Symbol & " " & ls_Value
            ls_QueryText = ls_Criteria & " " & ls_Symbol & " " & ls_Value
        Case "DATE"
            ls_Date = Mid(ls_Value, 2, Len(ls_Value) - 2)
            ls_Date = Mid(ls_Date, 4, 3) & Mid(ls_Date, 1, 3) & Mid(ls_Date, 7, 4)
            ls_DisplayText = ls_Trans & " " & ls_Symbol & " '" & ls_Date & "'"
            ls_QueryText = ls_Criteria & " " & ls_Symbol & " " & ls_Value
            gs_QueryIO(i) = QuoteParam(gs_QueryIO(i))
        Case "DATE2"
            ls_Date = Mid(ls_Value, 2, Len(ls_Value) - 2)
            ls_Date = Mid(ls_Date, 7, 2) & "/" & Mid(ls_Date, 5, 2) & "/" & Mid(ls_Date, 1, 4)
            ls_DisplayText = ls_Trans & " " & ls_Symbol & " '" & ls_Date & "'"
            ls_QueryText = ls_Criteria & " " & ls_Symbol & " " & ls_Value
            gs_QueryIO(i) = QuoteParam(gs_QueryIO(i))
        Case "VARCHAR", "VARLIKE"
            Select Case ls_Symbol
            Case "LIKE"
                ls_DisplayText = ls_Trans & ms_TransLike & "'" & Mid(ls_Value, 3, Len(ls_Value) - 4) & "'"
            Case Else
                ls_DisplayText = ls_Trans & " " & ls_Symbol & " " & ls_Value
            End Select
            ls_QueryText = ls_Criteria & " " & ls_Symbol & " '" & QuoteParam(Mid(ls_Value, 2, Len(ls_Value) - 2)) & "'"
            gs_QueryIO(i) = QuoteParam(gs_QueryIO(i))
        End Select
'       Build the new query
        lbl_Bureau(i) = ls_DisplayText
'       From clause
        ms_QueryArray(0, i, 0) = gut_Field(li_Count).FromClauseRes
        ms_QueryArray(0, i, 1) = gut_Field(li_Count).JoinClauseRes
        ms_QueryArray(0, i, 2) = gut_Field(li_Count).FromClauseExist
        ms_QueryArray(0, i, 3) = gut_Field(li_Count).FromClauseExist2
        ms_QueryArray(0, i, 4) = gut_Field(li_Count).JoinClauseExist
        ms_QueryArray(0, i, 5) = gut_Field(li_Count).JoinClauseExist2
        ms_QueryArray(0, i, 6) = ls_QueryText
        mb_FColStatus(i) = KO
    End If
Next i
For i = 10 To 59
    If gs_QueryIO(i) <> "" Then
        Select Case Mid(gs_QueryIO(i), 1, 1)
        Case "O"
            ls_Operator = "OR"
            ls_SelFields = right(gs_QueryIO(i), Len(gs_QueryIO(i)) - 3)
        Case "A"
            ls_Operator = "AND"
            ls_SelFields = right(gs_QueryIO(i), Len(gs_QueryIO(i)) - 4)
        End Select
        For j = 1 To Len(ls_SelFields) - 1 Step 2
            li_XYDesk = Mid(ls_SelFields, j, 2)
            li_XDesk = (li_XYDesk - 1) \ 10
            li_YDesk = li_XYDesk - (10 * li_XDesk) - 1
            mb_SelectLabel(li_XDesk, li_YDesk) = OK
            mb_UsedLabel(li_XDesk, li_YDesk) = OK
        Next j
        If ls_Operator = "OR" Then
            DisplayCellule ms_TransOr, "OR"
        Else
            DisplayCellule ms_TransAnd, "AND"
        End If
    End If
Next i
InitObjects

End Sub
Private Sub DisplayCellule(ls_Texte As String, ls_Condition As String)
' Display the condition at a calculated position on the desk
' 1. Determinate li_AndOrCol and li_AndOrRow to know where to display "ls_Texte"
' 2. Display "ls_Texte" in the right label (depending on li_AndOrCol and li_AndOrRow)
' 3. Draw the lines across the bureau from (li_AndOrCol,xh_y)
'    to all the selected items
' 4. update mb_UsedLabel(...) and ms_QueryArray(...) with
'    the content of all the selected items
Dim li_AndOrCol As Integer ' column where to display the OR and AND
Dim li_AndOrRow As Integer ' row where to display the OR and AND
Dim li_AndOrRowMin As Integer ' needed to calculate li_AndOrRow
Dim li_AndOrRowMax As Integer ' needed to calculate li_AndOrRow
Dim i As Integer, j As Integer
Dim li_StPointX As Integer, li_StPointY As Integer
Dim li_MaxPointY As Integer, li_MinPointY As Integer
Dim li_StPointX2 As Integer, li_StPointY2 As Integer
Dim li_WhereMax As Integer, li_WhereMin As Integer
Dim ls_ToBuild(9, 4) As String
Dim li_IndTB As Integer
Dim ls_Exists As String, ls_Where As String

li_AndOrCol = 0
li_AndOrRowMin = 10
li_AndOrRowMax = -1
For i = 0 To 9
    For j = 0 To 5
        If mb_SelectLabel(j, i) Then
            If j > li_AndOrCol Then
                li_AndOrCol = j
            End If
            If i < li_AndOrRowMin Then
                li_AndOrRowMin = i
                If j = 0 Then
                    li_WhereMin = 200
                Else
                    li_WhereMin = 0
                End If
            End If
            If i > li_AndOrRowMax Then
                li_AndOrRowMax = i
                If j = 0 Then
                    li_WhereMax = 200
                Else
                    li_WhereMax = 0
                End If
            End If
        End If
    Next j
Next i
li_AndOrRow = Int((li_AndOrRowMin + li_AndOrRowMax + 1) / 2)
lbl_Bureau(10 * (li_AndOrCol + 1) + li_AndOrRow) = ls_Texte
li_StPointX = 3000 + 1300 * li_AndOrCol
li_StPointY = 220 + 400 * li_AndOrRow
li_MaxPointY = 220 + 400 * li_AndOrRowMax + li_WhereMax
li_MinPointY = 220 + 400 * li_AndOrRowMin + li_WhereMin
pic_bureau.Line (li_StPointX - 50, li_StPointY)-(li_StPointX - 200, li_StPointY)
pic_bureau.Line (li_StPointX - 200, li_MaxPointY)-(li_StPointX - 200, li_MinPointY)
' FROM clause
ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 0) = ""
' Join clause
ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 1) = ""
' Next
ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 6) = "("
li_IndTB = 0
For i = 0 To 9
    For j = 0 To 4
        If mb_SelectLabel(j, i) Then
'        Selected item, part of the condition
'           Add the new main FROM clause to the existing one
            ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 0) = UnionForQuery(ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 0), ms_QueryArray(j, i, 0), ",")
'           Add the new main JOIN clause
            ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 1) = UnionForQuery(ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 1), ms_QueryArray(j, i, 1), " AND ")
            If j = 0 Then
'            Selected criteria
                li_StPointX2 = 2700
                li_StPointY2 = 420 + 400 * i
                If ms_QueryArray(j, i, 2) = "" Then
'                Only a single condition : added now
                    If ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 6) = "(" Then
'                    First condition
                        ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 6) = ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 6) & ms_QueryArray(j, i, 6)
                    Else
                        ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 6) = ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 6) & " " & ls_Condition & " " & ms_QueryArray(j, i, 6)
                    End If
                Else
'                Exists condition to build after
                    ls_ToBuild(li_IndTB, 0) = ms_QueryArray(j, i, 2)
                    ls_ToBuild(li_IndTB, 1) = ms_QueryArray(j, i, 3)
                    ls_ToBuild(li_IndTB, 2) = ms_QueryArray(j, i, 4)
                    ls_ToBuild(li_IndTB, 3) = ms_QueryArray(j, i, 5)
                    ls_ToBuild(li_IndTB, 4) = ms_QueryArray(j, i, 6)
                    li_IndTB = li_IndTB + 1
                End If
            Else
'            Already built condition
                li_StPointX2 = 2250 + 1300 * j
                li_StPointY2 = 220 + 400 * i
                If ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 6) = "(" Then
'                First condition
                    ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 6) = ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 6) & ms_QueryArray(j, i, 6)
                Else
                    ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 6) = ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 6) & " " & ls_Condition & " " & ms_QueryArray(j, i, 6)
                End If
            End If
            mb_UsedLabel(j, i) = OK
            pic_bureau.Line (li_StPointX - 200, li_StPointY2)-(li_StPointX2, li_StPointY2)
        End If
    Next j
Next i
If li_IndTB <> 0 Then
' Exists condition to build
'   1 : mix
    For i = 0 To li_IndTB - 2
'    For each exists to build
        For j = i + 1 To li_IndTB - 1
'        For each exists after
            If ls_ToBuild(j, 0) = ls_ToBuild(i, 0) And ls_ToBuild(j, 2) = ls_ToBuild(i, 2) Then
'            The first FROM clauses and the first JOIN clauses are the same
'               Mix the second FROM clauses
                ls_ToBuild(j, 1) = UnionForQuery(ls_ToBuild(i, 1), ls_ToBuild(j, 1), ",")
'               Mix the second JOIN clauses
                ls_ToBuild(j, 3) = UnionForQuery(ls_ToBuild(i, 3), ls_ToBuild(j, 3), " AND ")
                If ls_Condition = "AND" Then
                    ls_ToBuild(j, 4) = ls_ToBuild(i, 4) & " AND " & ls_ToBuild(j, 4)
                Else
'                OR condition
                    If Mid(ls_ToBuild(i, 4), 1, 1) = "(" Then
                        ls_ToBuild(j, 4) = Mid(ls_ToBuild(i, 4), 1, Len(ls_ToBuild(i, 4)) - 1) & " OR " & ls_ToBuild(j, 4) & ")"
                    Else
                        ls_ToBuild(j, 4) = "(" & ls_ToBuild(i, 4) & " OR " & ls_ToBuild(j, 4) & ")"
                    End If
                End If
'               This exists must not be mixed again
                ls_ToBuild(i, 0) = ""
            End If
        Next j
    Next i
'   2 : build
    For i = 0 To li_IndTB - 1
'    Build the final Exists for the whole condition
        If ls_ToBuild(i, 0) <> "" Then
'        Something to add
            ls_Exists = "EXISTS(SELECT 'LM' FROM "
            ls_Exists = ls_Exists & UnionForQuery(ls_ToBuild(i, 0), ls_ToBuild(i, 1), ",")
            ls_Exists = ls_Exists & " WHERE "
            ls_Where = UnionForQuery(ls_ToBuild(i, 2), ls_ToBuild(i, 3), " AND ")
            If ls_Where = "" Then
                ls_Exists = ls_Exists & ls_ToBuild(i, 4)
            Else
                ls_Exists = ls_Exists & ls_Where
                ls_Exists = ls_Exists & " AND " & ls_ToBuild(i, 4)
            End If
            ls_Exists = ls_Exists & ")"
            If ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 6) = "(" Then
            '    First condition
                ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 6) = ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 6) & ls_Exists
            Else
                ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 6) = ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 6) & " " & ls_Condition & " " & ls_Exists
            End If
        End If
    Next i
End If
ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 6) = ms_QueryArray(li_AndOrCol + 1, li_AndOrRow, 6) & ")"
' Save updates
PrepareSave ls_Condition, (li_AndOrCol + 1) * 10 + li_AndOrRow, ""
InitObjects

End Sub
Private Function FindCondParents() As String
' Build the string that will be saved as a condition beetween desk items
Dim i As Integer
Dim j As Integer

For i = 0 To 9
    For j = 0 To 5
        If mb_SelectLabel(j, i) Then
            FindCondParents = FindCondParents & Format(j * 10 + i + 1, "00")
        End If
    Next j
Next i

End Function
Private Sub PrepareSave(ls_Type As String, li_Position As Integer, ls_Text As String)
' Fill the array for query save
Select Case ls_Type
    Case "AND": gs_QueryIO(li_Position) = "AND " & FindCondParents
    Case "DELETE": gs_QueryIO(li_Position) = ""
    Case "OK": gs_QueryIO(li_Position) = QuoteParam(ls_Text)
    Case "OR": gs_QueryIO(li_Position) = "OR " & FindCondParents
End Select

End Sub
Private Sub InitObjects()
' Clear or/and Initialize each Control or Table
' When the "cancel","delete" or "blank page" PictureBox is selected
' Or when "DisplayCellule" function is activate
Dim i As Integer, j As Integer
Dim li_NbExit As Integer
Dim l As Integer

If cbo_Category.Enabled And cbo_Category.ListIndex = -1 Then
    pic_Load.Visible = KO
    lbl_Field.Visible = KO
    cbo_field.Visible = KO
    pic_Field.Visible = KO
Else
    pic_Load.Visible = OK
    lbl_Field.Visible = OK
    cbo_field.Visible = OK
    pic_Field.Visible = OK
    pic_Field.Enabled = OK
End If
mb_AddDeskLine = OK
For i = 0 To 59
    lbl_Bureau(i).ForeColor = BLACK
Next i
For i = 0 To 9
    For j = 0 To 5
        mb_SelectLabel(j, i) = KO
    Next j
Next i
mi_NbSelLabels = 0
li_NbExit = 0
For i = 0 To 9
    For j = 0 To 5
        If (ms_QueryArray(j, i, 6) <> "") And Not mb_UsedLabel(j, i) Then
            li_NbExit = li_NbExit + 1
        End If
    Next j
Next i
If li_NbExit = 1 Then
    pic_exec.Visible = OK
Else
    pic_exec.Visible = KO
End If
cbo_field.ListIndex = -1
pic_sup.Visible = KO
pic_sup_egal.Visible = KO
pic_inf.Visible = KO
pic_inf_egal.Visible = KO
pic_diff.Visible = KO
pic_egal.Visible = KO
pic_like.Visible = KO
HideValueEntry
pic_ok.Visible = KO
pic_cancel.Visible = KO
pic_delete.Visible = KO
pic_and.Visible = KO
pic_or.Visible = KO
pic_upd.Visible = KO
lbl_Info = ""
ms_Sign = ""
pic_new.Visible = KO
pic_Save.Visible = KO
For i = 0 To 9
    If lbl_Bureau(i) <> "" Then
        pic_new.Visible = OK
        pic_Save.Visible = OK
    End If
Next i

End Sub

Private Sub InitObjects2()
' Clear or/and Initialize each Control or Table
' When the "ok" PictureBox is selected
Dim i As Integer, j As Integer
Dim li_NbExit As Integer
Dim l As Integer
Dim lb_FreeLineFound As Boolean

'If Cbo_category.Enabled And Cbo_category.ListIndex = -1 Then
'    pic_Load.Visible = KO
'    lbl_field.Visible = KO
'    cbo_field.Visible = KO
'    pic_Field.Visible = KO
'Else
'    pic_Load.Visible = OK
'    lbl_field.Visible = OK
'    cbo_field.Visible = OK
'    pic_Field.Visible = OK
'    pic_Field.Enabled = OK
'End If
mb_AddDeskLine = OK
' reset all selected item
For i = 0 To 59
    lbl_Bureau(i).ForeColor = BLACK
Next i
For i = 0 To 9
    For j = 0 To 5
        mb_SelectLabel(j, i) = KO
    Next j
Next i
mi_NbSelLabels = 0
li_NbExit = 0
For i = 0 To 9
    For j = 0 To 5
        If (ms_QueryArray(j, i, 6) <> "") And Not mb_UsedLabel(j, i) Then
            li_NbExit = li_NbExit + 1
        End If
    Next j
Next i
If li_NbExit = 1 Then
    pic_exec.Visible = OK
Else
    pic_exec.Visible = KO
End If
'cbo_field.ListIndex = -1
'pic_sup.Visible = KO
'pic_sup_egal.Visible = KO
'pic_inf.Visible = KO
'pic_inf_egal.Visible = KO
'pic_diff.Visible = KO
'pic_egal.Visible = KO
'pic_like.Visible = KO
'HideValueEntry
'pic_ok.Visible = KO
'pic_cancel.Visible = KO
'pic_delete.Visible = KO
pic_and.Visible = KO
pic_or.Visible = KO
'pic_upd.Visible = KO
lbl_Info = ""
'ms_Sign = ""
pic_new.Visible = KO
pic_Save.Visible = KO
For i = 0 To 9
    If lbl_Bureau(i) <> "" Then
        pic_new.Visible = OK
        pic_Save.Visible = OK
    End If
Next i

 lb_FreeLineFound = KO
' search for a free line
For i = 0 To 9
    If mb_FColStatus(i) Then
        mi_FFLine = i
        lb_FreeLineFound = OK
        Exit For
    End If
Next i
If lb_FreeLineFound = KO Then
' no free line or nothing selected in cbo_field
'    If cbo_field.ListIndex <> -1 Then
'        SendMessage 66, "No more line available",gut_LangLogin.Code
'        cbo_field.ListIndex = -1
'    End If
    pic_Symbol.Visible = KO
    pic_cancel.Visible = KO
    pic_egal.Visible = KO
    pic_sup.Visible = KO
    pic_sup_egal.Visible = KO
    pic_inf.Visible = KO
    pic_inf_egal.Visible = KO
    pic_diff.Visible = KO
    pic_like.Visible = KO
    lbl_Value.Visible = KO
    txt_value.Visible = KO
    cbo_Value.Visible = KO
End If

End Sub

Private Function GetSelCriteria() As String

Dim i As Integer

GetSelCriteria = ""
For i = 0 To 9
    If lbl_Bureau(i).ForeColor = BLUE Then
        GetSelCriteria = GetCriteria(lbl_Bureau(i))
        Exit Function
    End If
Next i

End Function
Private Function GetCriteria(ls_DeskItem As String) As String
' For a given desk item, give the original criteria for cbo_field
Dim ls_Sign(6) As String
Dim i As Integer

ls_Sign(0) = " = "
ls_Sign(1) = " <> "
ls_Sign(2) = " >= "
ls_Sign(3) = " <= "
ls_Sign(4) = " > "
ls_Sign(5) = " < "
ls_Sign(6) = ms_TransLike
For i = 0 To 6
    If InStr(1, ls_DeskItem, ls_Sign(i), 1) > 0 Then
        GetCriteria = Left(ls_DeskItem, InStr(1, ls_DeskItem, ls_Sign(i), 1) - 1)
        Exit Function
    End If
Next i

End Function

Private Sub Cbo_category_Click()

MouseOff
If cbo_Category.ListIndex = -1 Then
    InitDesk
Else
    If gut_Param.Str1 = "Test" Then
        gut_Param.Str2 = "CAT_code"
        gut_Param.Str3 = cbo_CategoryCode.List(cbo_Category.ListIndex)
Else
    gut_Param.Str2 = "CG_code"
    gut_Param.Str3 = "'" & cbo_CategoryCode.List(cbo_Category.ListIndex) & "'"
    End If
    FillGrids
    InitDesk
End If
MouseOn

End Sub
Private Sub cbo_field_Click()
' Determinate the operators to show depending on the datatype of the selected criterion
Dim lb_FreeLineFound As Boolean
Dim i As Integer

MouseOff
pic_ok.Visible = KO
HideValueEntry
lb_FreeLineFound = KO
DeselectOp
If cbo_field.ListIndex <> -1 Then
    pic_Symbol.Visible = OK
' search for a free line
    For i = 0 To 9
        If mb_FColStatus(i) Then
            mi_FFLine = i
            lb_FreeLineFound = OK
            Exit For
        End If
    Next i
End If
If lb_FreeLineFound Then
' a free line exists
    pic_cancel.Visible = OK
    Select Case gut_Field(cbo_field.ItemData(cbo_field.ListIndex)).DataType
    Case "INTEGER", "NUMERIC", "DATE", "DATE2"
        pic_egal.Visible = OK
        pic_sup.Visible = OK
        pic_sup_egal.Visible = OK
        pic_inf.Visible = OK
        pic_inf_egal.Visible = OK
        pic_diff.Visible = OK
        pic_like.Visible = KO
    Case "VARCHAR"
        pic_egal.Visible = OK
        pic_sup.Visible = KO
        pic_sup_egal.Visible = KO
        pic_inf.Visible = KO
        pic_inf_egal.Visible = KO
        pic_diff.Visible = OK
        pic_like.Visible = OK
    Case "VARLIKE"
        pic_egal.Visible = KO
        pic_sup.Visible = KO
        pic_sup_egal.Visible = KO
        pic_inf.Visible = KO
        pic_inf_egal.Visible = KO
        pic_diff.Visible = KO
        pic_like.Visible = OK
    End Select
Else
' no free line or nothing selected in cbo_field
    If cbo_field.ListIndex <> -1 Then
        SendMessage 66, "No more line available", gut_LangLogin.Code
        cbo_field.ListIndex = -1
    End If
    pic_Symbol.Visible = KO
    pic_cancel.Visible = KO
    pic_egal.Visible = KO
    pic_sup.Visible = KO
    pic_sup_egal.Visible = KO
    pic_inf.Visible = KO
    pic_inf_egal.Visible = KO
    pic_diff.Visible = KO
    pic_like.Visible = KO
    lbl_Value.Visible = KO
    txt_value.Visible = KO
    cbo_Value.Visible = KO
End If
MouseOn

End Sub
Private Sub cbo_value_DblClick()
lbl_Info = "toto"
End Sub

Private Sub cmd_Date_Click()

MouseOff
gb_Return = KO
gs_Date = txt_value
Dates.show 1
If gb_Return Then
    txt_value = gs_Date
End If
MouseOn

End Sub
Private Sub cbo_value_Click()
' Display the ok button if a value is selected
MouseOff
If cbo_Value.ListIndex <> -1 Then
    pic_ok.Visible = OK
End If
MouseOn

End Sub
Private Sub Form_Load()

MouseOff

If gl_CodePage <> 1252 And gl_CodePage <> 0 Then ChangeCharset Me

pic_egal.Picture = LoadResPicture(RES_EQUAL, 1)
pic_diff.Picture = LoadResPicture(RES_DIFF, 1)
pic_like.Picture = LoadResPicture(RES_LIKE, 1)
pic_inf.Picture = LoadResPicture(RES_INF, 1)
pic_inf_egal.Picture = LoadResPicture(RES_INFEQUAL, 1)
pic_sup.Picture = LoadResPicture(RES_SUP, 1)
pic_sup_egal.Picture = LoadResPicture(RES_SUPEQUAL, 1)
pic_ok.Picture = LoadResPicture(RES_OK, 1)
pic_cancel.Picture = LoadResPicture(RES_CANCEL, 1)
pic_and.Picture = LoadResPicture(RES_AND, 1)
pic_or.Picture = LoadResPicture(RES_OR, 1)
pic_upd.Picture = LoadResPicture(RES_MODIFY, 1)
pic_delete.Picture = LoadResPicture(RES_DELETE, 1)
pic_exec.Picture = LoadResPicture(RES_FILLGRID, 1)
pic_new.Picture = LoadResPicture(RES_NEW, 1)
pic_Load.Picture = LoadResPicture(RES_OPEN, 1)
pic_Save.Picture = LoadResPicture(RES_FLOPPY, 1)
pic_quit.Picture = LoadResPicture(RES_QUIT, 1)
pic_Field.Picture = LoadResPicture(RES_COMBOCOPY, 1)

cmd_Date.Picture = LoadResPicture(RES_DOWN2, vbResIcon)

GetConstants
' Get the level of security for the current user
QuerySecurity
Select Case gut_Param.Str1
Case "Base_Item"
    FillCbo "Category", cbo_CategoryCode, cbo_Category
    frm_Filter.Visible = OK
    opt_All.Visible = OK
    opt_Dropped.Visible = OK
    opt_NonDropped.Visible = OK
Case "Claim"
    FillCbo "Category", cbo_CategoryCode, cbo_Category
    frm_Filter.Visible = OK
    opt_All.Visible = KO
    opt_Dropped.Visible = KO
    opt_NonDropped.Visible = KO
Case "sa_historic"
    frm_Filter.Visible = KO
    cbo_Category.Enabled = KO
    gut_Param.Str2 = "CG_code"
    gut_Param.Str3 = "''"
    FillGrids
Case "Test"
    FillCbo "Test_Category3", cbo_CategoryCode, cbo_Category
    frm_Filter.Visible = OK
    opt_All.Visible = OK
    opt_Dropped.Visible = OK
    opt_NonDropped.Visible = OK
End Select
InitDesk
MouseOn

End Sub
Private Sub Form_Unload(Cancel As Integer)

Erase gut_Field
Erase gut_Detail
Erase gut_SubDetail

End Sub

Private Sub lbl_Bureau_Click(Index As Integer)
' Select or unselect(if already selected) the clicked item on the desk
' and ask to determinate the available actions
Dim i As Integer
Dim j As Integer

MouseOff
i = Int(Index / 10)
j = Index - 10 * i
cbo_field.ListIndex = -1
If Not mb_SelectLabel(i, j) And lbl_Bureau(Index) <> "" Then
    lbl_Bureau(Index).ForeColor = BLUE
    mb_SelectLabel(i, j) = OK
    mi_NbSelLabels = mi_NbSelLabels + 1
    DisplayDeskButtons
Else
    If mb_SelectLabel(i, j) Then
        lbl_Bureau(Index).ForeColor = BLACK
        mb_SelectLabel(i, j) = KO
        mi_NbSelLabels = mi_NbSelLabels - 1
        DisplayDeskButtons
    End If
End If
MouseOn

End Sub
Private Sub lbl_Bureau_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)

lbl_Info = lbl_Bureau(Index)

End Sub
Private Sub lbl_Bureau_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)

lbl_Info = ""

End Sub


Private Sub pic_and_Click()
' An AND condition is choosen for selected items
MouseOff
' Display the condition on the desk
DisplayCellule ms_TransAnd, "AND"
' Display available actions
DisplayDeskButtons
MouseOn

End Sub

Private Sub pic_cancel_Click()
' Return to last desk state
MouseOff
InitObjects
MouseOn

End Sub
Private Sub pic_delete_Click()
' Clear the selected item from the desk
Dim i As Integer

MouseOff
For i = 0 To 9
    If lbl_Bureau(i).ForeColor = BLUE Then
'   A selected item
        lbl_Bureau(i) = ""
        PrepareSave "DELETE", i, ""
        mb_FColStatus(i) = OK
        ms_QueryArray(0, i, 0) = ""
        ms_QueryArray(0, i, 1) = ""
        ms_QueryArray(0, i, 2) = ""
        ms_QueryArray(0, i, 3) = ""
        ms_QueryArray(0, i, 4) = ""
        ms_QueryArray(0, i, 5) = ""
        ms_QueryArray(0, i, 6) = ""
    End If
Next i
InitObjects
MouseOn

End Sub
Private Sub pic_diff_Click()
' Operator choice
MouseOff
DeselectOp
pic_diff.BorderStyle = 1
ms_Sign = " <> "
ms_DisplaySign = " <> "
' Fill the value part depending on the selected operator
FillValue
MouseOn

End Sub
Private Sub pic_egal_Click()
' Operator choice
MouseOff
DeselectOp
pic_egal.BorderStyle = 1
ms_Sign = " = "
ms_DisplaySign = " = "
' Fill the value part depending on the selected operator
FillValue
MouseOn

End Sub
Private Sub pic_exec_Click()
' Execute the query drawn on the bureau,
' display the product the LixtBox "lst_result"
Dim i As Integer, j As Integer, k As Integer
Dim l As Integer, nb As Integer
Dim ls_FromClauseRes As String
Dim ls_JoinClauseRes As String
Dim ls_FromClauseExists As String
Dim ls_JoinClauseExists As String
Dim ls_ClauseExists As String
Dim lb_Found As Boolean

MouseOff
If gut_Param.Str6 = "" Then
' no description
    gut_Param.Str21 = "SELECT DISTINCT " & gut_Param.Str1 & "." & gut_Param.Str4
    ls_FromClauseRes = gut_Param.Str1
    ls_JoinClauseRes = ""
Else
    If mb_WorkingFiles = KO Then
        W_Plant
        W_Territory
        W_Claim
    End If
    
    gut_Param.Str21 = "SELECT DISTINCT " & gut_Param.Str1 & "." & gut_Param.Str4 & ", " _
                                & gut_Param.Str6 & "." & gut_Param.Str7
                                
    If gut_Param.Str1 = gut_Param.Str6 Then
        ls_FromClauseRes = gut_Param.Str1
    Else
        ls_FromClauseRes = gut_Param.Str1 & "," & gut_Param.Str6
    End If
    
    If gut_Param.Str1 = "Claim" Then
        ls_FromClauseRes = ls_FromClauseRes & ", #W_Claim "
    End If
        
    Select Case gut_Param.Str1
    Case "Claim"
        ls_JoinClauseRes = gut_Param.Str1 & ".Language_code = '" & gut_Param.Str5 & "'" _
        & " AND Claim.CLA_Code = #W_Claim.CLA_Code "
    Case "Base_Item"
        ls_JoinClauseRes = gut_Param.Str1 & "." & gut_Param.Str2 & " = " & gut_Param.Str3 _
            & " AND " & gut_Param.Str1 & ".Language_code = '" & gut_Param.Str5 & "'" _
            & " AND " & gut_Param.Str6 & "." & gut_Param.Str4 & " = " & gut_Param.Str1 & "." & gut_Param.Str4 _
            & " AND " & gut_Param.Str6 & ".Language_code = '" & gut_LangLogin.Code & "'"
        If opt_Dropped Then
            ls_JoinClauseRes = ls_JoinClauseRes & " AND Base_Item.drop_date_ind = 'Y'"
        ElseIf opt_NonDropped Then
            ls_JoinClauseRes = ls_JoinClauseRes & " AND Base_Item.drop_date_ind = 'N'"
        End If
    End Select
End If
lb_Found = KO
For j = 5 To 0 Step -1
    For i = 0 To 9
        If ms_QueryArray(j, i, 6) <> "" Then
            ls_FromClauseRes = UnionForQuery(ls_FromClauseRes, ms_QueryArray(j, i, 0), ",")
            ls_JoinClauseRes = UnionForQuery(ls_JoinClauseRes, ms_QueryArray(j, i, 1), " AND ")
            lb_Found = OK
            Exit For
        End If
    Next i
    If lb_Found Then
        Exit For
    End If
Next j
If j = 0 Then
' Single criteria
    If ms_QueryArray(j, i, 2) = "" Then
'    No Exists clause
        ls_JoinClauseRes = UnionForQuery(ls_JoinClauseRes, ms_QueryArray(j, i, 6), " AND ")
        ls_FromClauseExists = ""
        ls_ClauseExists = ""
    Else
'    Exists clause to build
        ls_FromClauseExists = UnionForQuery(ms_QueryArray(j, i, 2), ms_QueryArray(j, i, 3), ",")
        ls_ClauseExists = "EXISTS(SELECT 'LM' FROM " & ls_FromClauseExists
        ls_ClauseExists = ls_ClauseExists & " WHERE "
        ls_JoinClauseExists = UnionForQuery(ms_QueryArray(j, i, 4), ms_QueryArray(j, i, 5), " AND ")
        If ls_JoinClauseExists = "" Then
            ls_ClauseExists = ls_ClauseExists & ms_QueryArray(j, i, 6) & ")"
        Else
            ls_ClauseExists = ls_ClauseExists & ls_JoinClauseExists
            ls_ClauseExists = ls_ClauseExists & " AND " & ms_QueryArray(j, i, 6) & ")"
        End If
    End If
Else
    ls_ClauseExists = ms_QueryArray(j, i, 6)
End If
gut_Param.Str21 = gut_Param.Str21 & " FROM " & ls_FromClauseRes _
    & " WHERE " & ls_JoinClauseRes
If ls_ClauseExists <> "" Then
    If ls_JoinClauseRes = "" Then
        gut_Param.Str21 = gut_Param.Str21 & ls_ClauseExists
    Else
        gut_Param.Str21 = gut_Param.Str21 & " AND " & ls_ClauseExists
    End If
End If
gut_Param.Str21 = gut_Param.Str21 & " ORDER BY " & gut_Param.Str1 & "." & gut_Param.Str4

If CountSubFromNb(gut_Param.Str21) <= 16 Then
    Query_Result.show 1
Else
    SendMessage 76, "Your query is too long to be executed, please remove at least one condition.", gut_LangLogin.Code
End If
MouseOn

End Sub
Private Sub pic_Field_Click()

MouseOff
Query_Cbo.show 1
MouseOn

End Sub
Private Sub pic_inf_Click()
' Operator choice
MouseOff
DeselectOp
pic_inf.BorderStyle = 1
ms_Sign = " < "
ms_DisplaySign = " < "
' Fill the value part depending on the selected operator
FillValue
MouseOn

End Sub
Private Sub pic_inf_egal_Click()
' Operator choice
MouseOff
DeselectOp
pic_inf_egal.BorderStyle = 1
ms_Sign = " <= "
ms_DisplaySign = " <= "
' Fill the value part depending on the selected operator
FillValue
MouseOn

End Sub
Private Sub pic_like_Click()
' Operator choice
MouseOff
DeselectOp
pic_like.BorderStyle = 1
ms_Sign = " LIKE "
ms_DisplaySign = ms_TransLike
' Fill the value part depending on the selected operator
FillValue
MouseOn

End Sub
Private Sub pic_Load_Click()

MouseOff
gs_Action = "LOAD"
gut_Param.Str15 = ""
Query_Title.show 1
If gut_Param.Str15 <> "" Then
    If LoadQuery(Int(gut_Param.Str15)) Then
        RestoreQuery
    End If
End If
MouseOn

End Sub
Private Sub pic_new_Click()

MouseOff
InitDesk
MouseOn

End Sub
Private Sub pic_ok_Click()
' Change the current selection in a desk item
MouseOff
If mb_AddDeskLine Then
    CreateLine
Else
    UpdateLine
End If
InitObjects2
MouseOn

End Sub
Private Sub pic_or_Click()
' An OR condition is choosen for selected items
MouseOff
' Display the condition on the desk
DisplayCellule ms_TransOr, "OR"
' Display available actions
DisplayDeskButtons
MouseOn

End Sub


Private Sub pic_quit_Click()

MouseOff
If mb_WorkingFiles = OK Then
    W_FileDrop "Plant", ml_PlantStmt
    W_FileDrop "Claim", ml_ClaimStmt
    W_FileDrop "Territory", ml_TerritoryStmt
End If
mb_WorkingFiles = KO
Unload Me
MouseOn

End Sub
Private Sub pic_Save_Click()

MouseOff
gs_Action = "SAVE"
Query_Title.show 1
MouseOn

End Sub
Private Sub pic_sup_Click()
' Operator choice
MouseOff
DeselectOp
pic_sup.BorderStyle = 1
ms_Sign = " > "
ms_DisplaySign = " > "
' Fill the value part depending on the selected operator
FillValue
MouseOn

End Sub
Private Sub pic_sup_egal_Click()
' Operator choice
MouseOff
DeselectOp
pic_sup_egal.BorderStyle = 1
ms_Sign = " >= "
ms_DisplaySign = " >= "
' Fill the value part depending on the selected operator
FillValue
MouseOn

End Sub
Private Sub GetConstants()
' Get the translation of each label of the form from the screen_constants table
Dim ls_Field, ls_Text, ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer

On Error GoTo suite

ls_Req = "EXEC Screen_Csts 'Query_cst', '" & gut_LangLogin.Code & "'"
If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
    li_Status = SQL_SUCCESS
Else
    li_Status = SQL_ERROR
End If
Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
    li_Status = SQLFetch(ll_Statement)
    If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
        ls_Field = ODBCData(ll_Statement, 1)
        ls_Text = ODBCData(ll_Statement, 2)
        Select Case ls_Field
            Case "title": Caption = ls_Text & " : " & gut_Param.Str10
            Case "lbl_Title": lbl_Title = ls_Text
            Case "lbl_field": lbl_Field = ls_Text
            Case "lbl_value": ms_TransValue = ls_Text
            Case "lbl_result": lbl_Result = ls_Text
            Case "lbl_result2": lbl_Result2 = ls_Text
            Case "lbl_Detail": lbl_Detail = ls_Text
            Case "lbl_Start": Lbl_start = ls_Text
            Case "date": ms_TransDate = ls_Text
            Case "or": ms_TransOr = ls_Text
            Case "and": ms_TransAnd = ls_Text
            Case "general": ms_TransGeneral = ls_Text
            Case "like": ms_TransLike = " " & ls_Text & " "
            Case "frm_Filter": frm_Filter.Caption = ls_Text
            Case "lbl_Category": lbl_Category = ls_Text
            Case "opt_All": opt_All.Caption = ls_Text
            Case "opt_Dropped": opt_Dropped.Caption = ls_Text
            Case "opt_NonDropped": opt_NonDropped.Caption = ls_Text
        End Select
    End If
Loop
SQLFreeStatement ll_Statement, SQL_DROP
Exit Sub

suite:
SQLFreeStatement ll_Statement, SQL_DROP
StdError
End Sub
Private Sub pic_upd_Click()
' Update the selected item on the desk
MouseOff
mb_AddDeskLine = KO
cbo_field.ListIndex = ComboFindItem(cbo_field, GetSelCriteria)
pic_Field.Enabled = KO
MouseOn

End Sub
Private Sub txt_value_Change()

If txt_value.Visible Then
    pic_ok.Visible = OK
End If

End Sub

Private Sub txt_value_LostFocus()
' Control and adjust value depending on the wanted datatype
MouseOff
' Datatype for current row in grid
If cbo_field.ListIndex <> -1 Then
    Select Case gut_Field(cbo_field.ItemData(cbo_field.ListIndex)).DataType
    Case "INTEGER"
        txt_value = Int(Val(txt_value))
    Case "NUMERIC"
        If Not CheckNumericValue(txt_value) Then
            SendMessage 18, "Only numeric field is valid ", gut_LangLogin.Code
            txt_value.SetFocus
            MouseOn
            Exit Sub
        End If
    End Select
    pic_ok.Visible = OK
End If
MouseOn

End Sub
Private Sub HideValueEntry()

lbl_Value.Visible = KO
txt_value.Visible = KO
txt_value = ""
cmd_Date.Visible = KO
cbo_Value.Visible = KO
cbo_Value.Clear

End Sub
Private Sub DeselectOp()
' Deslect all the operators
pic_egal.BorderStyle = 0
pic_sup.BorderStyle = 0
pic_sup_egal.BorderStyle = 0
pic_inf.BorderStyle = 0
pic_inf_egal.BorderStyle = 0
pic_diff.BorderStyle = 0
pic_like.BorderStyle = 0

End Sub
Private Function LoadQuery(a_Code As Integer) As Boolean

Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim li_Order As Integer
Dim ls_Text As String

LoadQuery = KO

On Error GoTo suite

InitDesk
ls_Req = "EXEC Query_Save_Detail_lst " _
    & a_Code
If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
    LoadQuery = OK
    li_Status = SQL_SUCCESS
Else
    li_Status = SQL_ERROR
End If
Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
    li_Status = SQLFetch(ll_Statement)
    If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
        li_Order = ODBCData(ll_Statement, 1)
        gs_QueryIO(li_Order) = ODBCData(ll_Statement, 2)
    End If
Loop
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
Exit Function

suite:
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
StdError
End Function
Public Function SaveQuery(a_Code As Integer) As Boolean

Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim i As Integer

SaveQuery = KO

On Error GoTo suite

For i = 0 To 59
    If gs_QueryIO(i) <> "" Then
        ls_Req = ls_Req & "EXEC Query_Save_Detail_ins " _
            & a_Code & ", " _
            & i & ",'" _
            & gs_QueryIO(i) & "'" & Chr(13) & Chr(10)
    End If
Next i
If ls_Req <> "" Then
    If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        SaveQuery = OK
    Else
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        SendMessage 4, "Insert failed", gut_LangLogin.Code
    End If
Else
    SaveQuery = OK
End If
Exit Function

suite:
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
StdError
End Function
