VERSION 5.00
Object = "{0D452EE1-E08F-101A-852E-02608C4D0BB4}#2.0#0"; "FM20.DLL"
Begin VB.Form C_address_mtnc 
   BorderStyle     =   3  'Fixed Dialog
   ClientHeight    =   5220
   ClientLeft      =   6105
   ClientTop       =   1680
   ClientWidth     =   7485
   ClipControls    =   0   'False
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   5220
   ScaleWidth      =   7485
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton ssp_quit 
      Height          =   615
      Left            =   6780
      Style           =   1  'Graphical
      TabIndex        =   17
      Top             =   4560
      Width           =   615
   End
   Begin VB.CommandButton spp_save 
      Height          =   615
      Left            =   6060
      Style           =   1  'Graphical
      TabIndex        =   18
      Top             =   4560
      Width           =   615
   End
   Begin VB.TextBox txt_Name 
      Height          =   288
      Left            =   1740
      MaxLength       =   80
      TabIndex        =   0
      Top             =   120
      Width           =   5412
   End
   Begin VB.Frame frm_Contact 
      Height          =   1935
      Left            =   0
      TabIndex        =   19
      Top             =   2520
      Width           =   7392
      Begin VB.TextBox txt_Email 
         Height          =   288
         Left            =   1740
         MaxLength       =   80
         TabIndex        =   12
         Top             =   1560
         Width           =   5412
      End
      Begin VB.TextBox txt_ContactTitle 
         Height          =   288
         Left            =   1740
         MaxLength       =   80
         TabIndex        =   8
         Top             =   660
         Width           =   5412
      End
      Begin VB.TextBox txt_Contact 
         Height          =   288
         Left            =   1740
         MaxLength       =   80
         TabIndex        =   7
         Top             =   240
         Width           =   5412
      End
      Begin VB.TextBox txt_Fax 
         Height          =   285
         Left            =   5100
         MaxLength       =   20
         TabIndex        =   11
         Top             =   1140
         Width           =   2055
      End
      Begin VB.TextBox txt_Tel 
         Height          =   285
         Left            =   1740
         MaxLength       =   20
         TabIndex        =   9
         Top             =   1140
         Width           =   1935
      End
      Begin VB.Label lbl_Email 
         Caption         =   "E-mail"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   60
         TabIndex        =   27
         Top             =   1560
         Width           =   1680
      End
      Begin VB.Label lbl_ContactTitle 
         Caption         =   "Contact title"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   60
         TabIndex        =   23
         Top             =   720
         Width           =   1680
      End
      Begin VB.Label lbl_Contact 
         Caption         =   "Contact"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   252
         Left            =   60
         TabIndex        =   22
         Top             =   240
         Width           =   1680
      End
      Begin VB.Label lbl_Fax 
         Caption         =   "Fax"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   3780
         TabIndex        =   21
         Top             =   1140
         Width           =   1320
      End
      Begin VB.Label lbl_Tel 
         Caption         =   "Phone"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   60
         TabIndex        =   20
         Top             =   1140
         Width           =   1680
      End
   End
   Begin VB.TextBox txt_Address1 
      Height          =   288
      Left            =   1740
      MaxLength       =   80
      TabIndex        =   1
      Top             =   504
      Width           =   5412
   End
   Begin VB.TextBox txt_Address2 
      Height          =   288
      Left            =   1740
      MaxLength       =   80
      TabIndex        =   2
      Top             =   888
      Width           =   5412
   End
   Begin VB.TextBox txt_Town 
      Height          =   288
      Left            =   1740
      MaxLength       =   80
      TabIndex        =   4
      Top             =   1653
      Width           =   1815
   End
   Begin VB.TextBox txt_Zip 
      Height          =   285
      Left            =   1740
      MaxLength       =   15
      TabIndex        =   3
      Top             =   1272
      Width           =   1815
   End
   Begin MSForms.ComboBox cbo_Company 
      Height          =   315
      Left            =   1740
      TabIndex        =   6
      Top             =   1980
      Width           =   1815
      VariousPropertyBits=   679479323
      DisplayStyle    =   7
      Size            =   "3201;556"
      ColumnCount     =   2
      MatchEntry      =   1
      ShowDropButtonWhen=   2
      FontHeight      =   165
      FontCharSet     =   0
      FontPitchAndFamily=   2
   End
   Begin MSForms.ComboBox cbo_CustType 
      Height          =   315
      Left            =   5340
      TabIndex        =   26
      Top             =   2040
      Width           =   2055
      VariousPropertyBits=   679479323
      DisplayStyle    =   7
      Size            =   "3625;556"
      MatchEntry      =   1
      ShowDropButtonWhen=   2
      FontHeight      =   165
      FontCharSet     =   0
      FontPitchAndFamily=   2
   End
   Begin MSForms.ComboBox cbo_Country 
      Height          =   315
      Left            =   5340
      TabIndex        =   5
      Top             =   1650
      Width           =   2055
      VariousPropertyBits=   679479323
      DisplayStyle    =   7
      Size            =   "3625;556"
      MatchEntry      =   1
      ShowDropButtonWhen=   2
      FontHeight      =   165
      FontCharSet     =   0
      FontPitchAndFamily=   2
   End
   Begin VB.Label lbl_CustType 
      Caption         =   "Customer type"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   3720
      TabIndex        =   25
      Top             =   2040
      Width           =   1680
   End
   Begin VB.Label lbl_Company 
      Caption         =   "Company"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   60
      TabIndex        =   24
      Top             =   2040
      Width           =   1680
   End
   Begin VB.Label lbl_Name 
      Caption         =   "Name"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   60
      TabIndex        =   16
      Top             =   120
      Width           =   1680
   End
   Begin VB.Label lbl_Address 
      Caption         =   "Address"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   252
      Left            =   60
      TabIndex        =   15
      Top             =   504
      Width           =   1680
   End
   Begin VB.Label lbl_Town 
      Caption         =   "Town"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   252
      Left            =   60
      TabIndex        =   14
      Top             =   1653
      Width           =   1680
   End
   Begin VB.Label lbl_Country 
      Caption         =   "Country"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   3720
      TabIndex        =   13
      Top             =   1650
      Width           =   1680
   End
   Begin VB.Label lbl_Zip 
      BackColor       =   &H00C0C0C0&
      Caption         =   "Zip code"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   252
      Left            =   60
      TabIndex        =   10
      Top             =   1272
      Width           =   1680
   End
End
Attribute VB_Name = "C_address_mtnc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim mb_CountryNotLoaded As Boolean
Public ms_CompCode As String
Public ms_CTCode As String
Public ms_CompanyName As String

Private Sub ObjectBehavior(mb_Enabled As Boolean, mb_Locked As Boolean)
'------------------------------------------------------------------
' Purpose : Enabled or disabled, locked or unlocked components
'
' Parameters :
'               mb_Enabled: Set enabled or disabled (OK or KO)
'               mb_Locked: Set enabled or disabled (OK or KO)
'
' review : Apr./7/2000 by TM
'------------------------------------------------------------------
Dim ls_Count As Integer

For ls_Count = 0 To Me.Count - 1
    If UCase(Me.Controls(ls_Count).Name) Like "TXT_*" Or UCase(Me.Controls(ls_Count).Name) Like "CBO_*" Then
        Me.Controls(ls_Count).Enabled = mb_Enabled
        Me.Controls(ls_Count).Locked = mb_Locked
    End If
    If UCase(Me.Controls(ls_Count).Name) Like "LBL_*" Then
        Me.Controls(ls_Count).Enabled = mb_Enabled
    End If
Next

End Sub
Private Sub cbo_Company_DropbuttonClick()
Dim ls_Req As String
Dim ls_Code
    
If cbo_Company.Tag = Loaded Then Exit Sub

MouseOff
ls_Code = MCombo_GetCode(cbo_Company)
cbo_Company.Clear

ls_Req = "EXEC companies_cbo "
MCombo_Fill cbo_Company, ls_Req
MCombo_CodeSelect(cbo_Company) = ls_Code
cbo_Company.Tag = Loaded
MouseOn

End Sub

Private Sub Cbo_country_Click()

MouseOff
If cbo_Country.ListIndex <> -1 And cbo_Country.Visible = -1 Then
    If cbo_Country.Column(2) = 1 Then
        SendMessage 70, "Inactive item", gut_LangLogin.Code
    End If
End If
MouseOn

End Sub
Private Sub Cbo_country_DropButtonClick()
Dim ls_Req As String
Dim ls_Code
    
    If cbo_Country.Tag = Loaded Then Exit Sub
    
    MouseOff
    ls_Code = MCombo_GetCode(cbo_Country)
    cbo_Country.Clear
    
    ls_Req = "EXEC countries_cbo '" & gut_LangWork.Code & "'"
    MCombo_Fill cbo_Country, ls_Req
    MCombo_CodeSelect(cbo_Country) = ls_Code
    cbo_Country.Tag = Loaded
    MouseOn

End Sub

Private Sub cbo_CustType_Click()
MouseOff
If cbo_CustType.ListIndex <> -1 And cbo_CustType.Visible = -1 Then
    If cbo_CustType.Column(2) = 1 Then
        SendMessage 70, "Inactive item", gut_LangLogin.Code
    End If
End If
MouseOn

End Sub

Private Sub cbo_CustType_DropButtonClick()
Dim ls_Req As String
Dim ls_Code

    If cbo_CustType.Tag = Loaded Then Exit Sub

    MouseOff
    ls_Code = MCombo_GetCode(cbo_CustType)
    cbo_CustType.Clear
    ls_Req = "EXEC CustomerType_cbo '" & gut_LangWork.Code & "'"
    MCombo_Fill cbo_CustType, ls_Req
    
    MCombo_CodeSelect(cbo_CustType) = ls_Code
    cbo_CustType.Tag = Loaded
    MouseOn

End Sub

Private Sub Form_Load()

On Error GoTo suite

MouseOff

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

spp_save.Picture = LoadResPicture(RES_OK, 1)
ssp_quit.Picture = LoadResPicture(RES_QUIT, 1)
Getcsts
mb_CountryNotLoaded = OK
Select Case gut_Param2.Str2
Case "Add"
    Select Case gut_Param2.Str1
    Case "Claim_Customer"
        frm_Contact.Visible = OK
    Case "Claim_Project"
        frm_Contact.Visible = KO
    Case "Quotation"
        frm_Contact.Visible = OK
    End Select
Case Else
    txt_Name = gut_Param2.Str6
    txt_Address1 = gut_Param2.Str7
    txt_Address2 = gut_Param2.Str8
    txt_Zip = gut_Param2.Str9
    txt_Town = gut_Param2.Str10
    
    MCombo_AddItemCode cbo_Country, gut_Param2.Str11, gut_Param2.Str12
    MCombo_AddItemCode cbo_Company, ms_CompCode, ms_CompanyName
    MCombo_AddItemCode cbo_CustType, C_Selection.ms_CustTCode, C_Selection.ms_CustTDesc
    
    txt_ContactTitle = C_Selection.ms_ContactTitle
    txt_Email = C_Selection.ms_Email
    Select Case gut_Param2.Str1
    Case "Claim_Customer"
        frm_Contact.Visible = OK
        txt_Contact = gut_Param2.Str13
        txt_Tel = gut_Param2.Str14
        txt_Fax = gut_Param2.Str15
    Case "Quotation_Customer"
        frm_Contact.Visible = OK
        txt_Contact = gut_Param2.Str13
        txt_Tel = gut_Param2.Str14
        txt_Fax = gut_Param2.Str15
    Case "Claim_Project"
        frm_Contact.Visible = KO
    End Select
End Select

' If Detail only
If gut_Param2.Str2 = "Detail" Then
    ObjectBehavior KO, KO
    ssp_quit.Enabled = OK
    spp_save.Visible = KO
End If

cbo_Country.Tag = UNLOADED
cbo_Company.Tag = UNLOADED
cbo_CustType.Tag = UNLOADED
MouseOn
Exit Sub

suite:
StdError
End Sub

Private Sub spp_save_Click()

MouseOff
Select Case gut_Param2.Str2
Case "Add"
    If AddRow Then
        gb_Return = OK
        Unload Me
    End If
Case "Update"
    If UpdateRow Then
        gb_Return = OK
        Unload Me
    End If
End Select
MouseOn

End Sub
Private Sub ssp_quit_Click()

MouseOff
Unload Me
MouseOn

End Sub
Private Function UpdateRow() As Boolean

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

UpdateRow = KO

On Error GoTo suite

If Control Then
    gut_Param2.Str6 = txt_Name
    gut_Param2.Str7 = txt_Address1
    gut_Param2.Str8 = txt_Address2
    gut_Param2.Str9 = txt_Zip
    gut_Param2.Str10 = txt_Town
    If cbo_Country.ListIndex = -1 Then
        gut_Param2.Str11 = ""
        gut_Param2.Str12 = ""
    Else
        gut_Param2.Str11 = MCombo_GetCode(cbo_Country)
        gut_Param2.Str12 = cbo_Country.value
    End If
    Select Case gut_Param2.Str1
    Case "Claim_Customer"
        gut_Param2.Str13 = txt_Contact
        gut_Param2.Str14 = txt_Tel
        gut_Param2.Str15 = txt_Fax
        ls_Req = "EXEC Claim_Customer_upd " _
            & gut_Param2.Str4 & ", '" & QuoteParam(gut_Param2.Str6) & "', '" _
            & QuoteParam(gut_Param2.Str7) & "', '" & QuoteParam(gut_Param2.Str8) & "', '" _
            & QuoteParam(gut_Param2.Str9) & "', '" & QuoteParam(gut_Param2.Str10) & "', '" _
            & gut_Param2.Str11 & "', '" & QuoteParam(gut_Param2.Str13) & "', '" _
            & QuoteParam(gut_Param2.Str14) & "', '" & QuoteParam(gut_Param2.Str15) & "','" _
            & QuoteParam(MCombo_GetCode(cbo_CustType)) & "', 1, '" & QuoteParam(txt_ContactTitle) & "', '" _
            & QuoteParam(MCombo_GetCode(cbo_Company)) & "','" & QuoteParam(txt_Email) & "', " & gut_Param2.Str5
    Case "Quotation_Customer"
        gut_Param2.Str13 = txt_Contact
        gut_Param2.Str14 = txt_Tel
        gut_Param2.Str15 = txt_Fax
        ls_Req = "EXEC Claim_Customer_upd " _
            & gut_Param2.Str4 & ", '" & QuoteParam(gut_Param2.Str6) & "', '" _
            & QuoteParam(gut_Param2.Str7) & "', '" & QuoteParam(gut_Param2.Str8) & "', '" _
            & QuoteParam(gut_Param2.Str9) & "', '" & QuoteParam(gut_Param2.Str10) & "', '" _
            & gut_Param2.Str11 & "', '" & QuoteParam(gut_Param2.Str13) & "', '" _
            & QuoteParam(gut_Param2.Str14) & "', '" & QuoteParam(gut_Param2.Str15) & "','" _
            & QuoteParam(MCombo_GetCode(cbo_CustType)) & "', 2 , '" & QuoteParam(txt_ContactTitle) & "', '" _
            & QuoteParam(MCombo_GetCode(cbo_Company)) & "','" & QuoteParam(txt_Email) & "', " & gut_Param2.Str5
    Case "Claim_Project"
        ls_Req = "EXEC Claim_Project_upd " _
            & gut_Param2.Str4 & ", '" _
            & QuoteParam(gut_Param2.Str6) & "', '" _
            & QuoteParam(gut_Param2.Str7) & "', '" & QuoteParam(gut_Param2.Str8) & "', '" _
            & QuoteParam(gut_Param2.Str9) & "', '" & QuoteParam(gut_Param2.Str10) & "', '" _
            & gut_Param2.Str11 & "', " _
            & gut_Param2.Str5
    End Select
    If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
        li_Status = SQLRowCount(ll_Statement, ll_lngrows)
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        If ll_lngrows = 0 Then
            SendMessage 2, "Another user changed the record", gut_LangLogin.Code
        Else
            UpdateRow = OK
            gut_Param2.Str5 = CInt(gut_Param2.Str5) + 1
        End If
    Else
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        SendMessage 2, "Another user changed the record", gut_LangLogin.Code
    End If
End If
Exit Function

suite:
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
StdError
End Function
Private Function AddRow() As Boolean

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

AddRow = KO

On Error GoTo suite

If Control Then
    gut_Param2.Str6 = txt_Name
    gut_Param2.Str7 = txt_Address1
    gut_Param2.Str8 = txt_Address2
    gut_Param2.Str9 = txt_Zip
    gut_Param2.Str10 = txt_Town
    If cbo_Country.ListIndex = -1 Then
        gut_Param2.Str11 = ""
        gut_Param2.Str12 = ""
    Else
        gut_Param2.Str11 = MCombo_GetCode(cbo_Country)
        gut_Param2.Str12 = cbo_Country.value
        
    End If
    Select Case gut_Param2.Str1
    Case "Claim_Customer"
        gut_Param2.Str13 = txt_Contact
        gut_Param2.Str14 = txt_Tel
        gut_Param2.Str15 = txt_Fax
        ls_Req = "EXEC Claim_Customer_ins '" _
            & QuoteParam(gut_Param2.Str6) & "', '" & QuoteParam(gut_Param2.Str7) & "', '" & QuoteParam(gut_Param2.Str8) & "', '" _
            & QuoteParam(gut_Param2.Str9) & "', '" & QuoteParam(gut_Param2.Str10) & "', '" _
            & gut_Param2.Str11 & "', '" & QuoteParam(gut_Param2.Str13) & "', '" _
            & QuoteParam(gut_Param2.Str14) & "', '" & QuoteParam(gut_Param2.Str15) & "','" _
            & QuoteParam(MCombo_GetCode(cbo_CustType)) & "', 1,'" & QuoteParam(txt_ContactTitle) & "','" _
            & QuoteParam(MCombo_GetCode(cbo_Company)) & "','" & QuoteParam(txt_Email) & "'"
    Case "Quotation_Customer"
        gut_Param2.Str13 = txt_Contact
        gut_Param2.Str14 = txt_Tel
        gut_Param2.Str15 = txt_Fax
        ls_Req = "EXEC Claim_Customer_ins '" _
            & QuoteParam(gut_Param2.Str6) & "', '" _
            & QuoteParam(gut_Param2.Str7) & "', '" & QuoteParam(gut_Param2.Str8) & "', '" _
            & QuoteParam(gut_Param2.Str9) & "', '" & QuoteParam(gut_Param2.Str10) & "', '" _
            & gut_Param2.Str11 & "', '" _
            & QuoteParam(gut_Param2.Str13) & "', '" _
            & QuoteParam(gut_Param2.Str14) & "', '" & QuoteParam(gut_Param2.Str15) & "','" _
            & QuoteParam(MCombo_GetCode(cbo_CustType)) & "', 2,'" & QuoteParam(txt_ContactTitle) & "','" _
            & QuoteParam(MCombo_GetCode(cbo_Company)) & "','" & QuoteParam(txt_Email) & "'"
    Case "Claim_Project"
        ls_Req = "EXEC Claim_Project_ins '" _
            & QuoteParam(gut_Param2.Str6) & "', '" _
            & QuoteParam(gut_Param2.Str7) & "', '" & QuoteParam(gut_Param2.Str8) & "', '" _
            & QuoteParam(gut_Param2.Str9) & "', '" & QuoteParam(gut_Param2.Str10) & "', '" _
            & gut_Param2.Str11 & "'"
    End Select
    If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
    li_Status = SQLRowCount(ll_Statement, ll_lngrows)
        If ll_lngrows = 0 Then
            li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
            SendMessage 4, "Insert failed", gut_LangLogin.Code
        Else
            AddRow = OK
            li_Status = SQLFetch(ll_Statement)
            If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
                gut_Param2.Str4 = ODBCData(ll_Statement, 1)
            End If
            li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
            gut_Param2.Str5 = "1"
        End If
    Else
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        SendMessage 4, "Insert failed", gut_LangLogin.Code
    End If
End If
Exit Function

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

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

On Error GoTo suite

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, gut_Param2.Str3) 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 = left(ODBCData(ll_Statement, 2), 30)
        Select Case ls_Field
            Case "title": Caption = ls_Text
            Case "titleA": If gs_Action = "Add" Then Caption = Caption & " - " & ls_Text
            Case "titleU": If gs_Action = "Update" Then Caption = Caption & " - " & ls_Text
            Case "titleD": If gs_Action = "Delete" Then Caption = Caption & " - " & ls_Text
            Case "titleI": If gs_Action = "MoreInfo" Then Caption = Caption & " - " & ls_Text
            Case "lbl_Name": lbl_Name = ls_Text
            Case "lbl_Address": lbl_Address = ls_Text
            Case "lbl_Zip": lbl_Zip = ls_Text
            Case "lbl_Town": lbl_Town = ls_Text
            Case "lbl_Country": lbl_Country = ls_Text
            Case "lbl_Contact": lbl_Contact.Caption = ls_Text
            Case "lbl_Tel": lbl_Tel.Caption = ls_Text
            Case "lbl_Fax": lbl_Fax = ls_Text
        End Select
    End If
Loop
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
Exit Sub

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


Private Function Control() As Boolean

Control = KO
If txt_Name.Text = "" Then
    txt_Name.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If

If cbo_Country.value = "" Then
    cbo_Country.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
    
If txt_Town = "" Then
    txt_Town.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
    
If gut_Param.Str2 = "Quotation" Then
    If cbo_Company.ListIndex = -1 Or MCombo_GetCode(cbo_Company) = "" Then
        cbo_Company.SetFocus
        SendMessage 8, "Value must be filled in", gut_LangLogin.Code
        Exit Function
    End If
End If
Control = OK

End Function


