Dim CurrentControl As Integer
Dim Codesearch As Boolean
Dim Searchstring As String
Dim Work As String
Dim RefNo as Long
Dim Ds as Long


Private Sub TxtClass_KeyDown(KeyCode As Integer, Shift As Integer)
End Sub




Private Sub TxtClass_GotFocus()
 ChangeColor TxtClass
End Sub
Function Valid() as boolean
Valid=True

If  trim(TxtClass)="" then 
           TxtClass.Setfocus : Valid=False : Msgbox "Enter "
End if
End Function
Private Sub Form_Load(): Paintcontrols me 
         Work ="A"

End Sub
  Private Sub MsfList_KeyDown(KeyCode As Integer, Shift As Integer)
         If KeyCode = 27 Then
             FraList.Visible = False
             Exit Sub
         ElseIf KeyCode = 13 And MsfList.Cols > 1 Then
             Ds=Val(MsfList.TextMatrix(MsfList.Row, 0))
             FraList.Visible = False
             Exit Sub
         Else
             FlexSearch KeyCode, False, Searchstring, Me, MsfList
         End If
End Sub
Private Sub MSFLIST_EnterCell()
         MsfList.Col = 0
End Sub
Private Sub MsfList_DblClick()
         MsfList_KeyDown 13, 0
End Sub
Function GetQuery() As String
         Dim s As String
         Select Case (CurrentControl)
                 Case 1:
              s ="select Ds_RefNo from Dmg_sub  where Ds_RefNo like '"& Trim(Searchstring)&"%' order by Ds_RefNo"
         End Select
             MsfList.ColWidth(0) = 1000
             MsfList.ColWidth(1) = 1000
GetQuery = s
End Function
Private sub CmdAdd_Click()
 Currentcontrol=1
 Work ="A"
 Clear Me
 Fralist.Visible=False
End sub








Private Sub CmdModify_Click()
    Work ="M"
    Clear Me
    CurrentControl = 1
    FlexSearch 46, False, Searchstring, Me, MsfList
    FraList.Visible = True
    MsfList.SetFocus
Dim ObjDs As New Dmgsub
WIth ObjDs
.Ds=Ds
.GetDmg_sub
      TxtClAcCd  =.DsClAcCd
      TxtDate  =.DsDate
      TxtDisAmt  =.DsDisAmt
      TxtDisPer  =.DsDisPer
      TxtGross  =.DsGross
      TxtInvNo  =.DsInvNo
      TxtItCd  =.DsItCd
      TxtItName  =.DsItName
      TxtQty  =.DsQty
      TxtRate  =.DsRate
      TxtRefNo  =.DsRefNo
      TxtSlNo  =.DsSlNo
      Txttax  =.Dstax
      TxtTaxPer  =.DsTaxPer

End With
End sub




Private Sub CmdDelete_Click()
    Work ="D"
    Clear Me
    CurrentControl = 0
    FlexSearch 46, False, Searchstring, Me, MsfList
    FraList.Visible = True
    MsfList.SetFocus
End sub




Private Sub CmdClose_Click()
Unload me
End sub




Private Sub CmdSave_Click()
If Valid=false then
Exit sub
End If
Dim ObjDs As New Dmgsub
With ObjDs
     .DsClAcCd = trim(TxtClAcCd)
     .DsDate = TxtDate
     .DsDisAmt = Val(TxtDisAmt)
     .DsDisPer = Val(TxtDisPer)
     .DsGross = Val(TxtGross)
     .DsInvNo = trim(TxtInvNo)
     .DsItCd = Val(TxtItCd)
     .DsItName = trim(TxtItName)
     .DsQty = Val(TxtQty)
     .DsRate = Val(TxtRate)
     .DsRefNo = Val(TxtRefNo)
     .DsSlNo = val(TxtSlNo)
     .Dstax = Val(Txttax)
     .DsTaxPer = Val(TxtTaxPer)

if Work = "A" Then
    .SaveDmg_sub true
Elseif Work = "M" Then
    .SaveDmg_sub false
End If
End With 
  Clear Me
If Work ="M"Then
CmdModify_Click
ElseIf Work = "A" Then
CmdAdd_Click

ElseIf Work = "V" Then
CmdView_Click

End If
End sub




Private Sub CmdView_Click()
  FrmViewReport.show
End Sub
Private Sub Form_Unload(Cancel As Integer)
       ChangeColor , , True
End Sub
