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


Private Sub TxtName_KeyDown(KeyCode As Integer, Shift As Integer)
    If Keycode=13 then
         TxtLisName.setfocus
    End If
End Sub




Private Sub TxtName_GotFocus()
 ChangeColor TxtName
End Sub


Private Sub TxtLisName_KeyDown(KeyCode As Integer, Shift As Integer)
    If Keycode=13 then
         TxtcRdR.setfocus
    Elseif KeyCode=38 then
         TxtName.setfocus
    End If
End Sub




Private Sub TxtLisName_GotFocus()
 ChangeColor TxtLisName
End Sub


Private Sub TxtcRdR_KeyDown(KeyCode As Integer, Shift As Integer)
    If Keycode=13 then
         TxtFs.setfocus
    Elseif KeyCode=38 then
         TxtLisName.setfocus
    End If
End Sub




Private Sub TxtcRdR_GotFocus()
 ChangeColor TxtcRdR
End Sub


Private Sub TxtFs_KeyDown(KeyCode As Integer, Shift As Integer)
    If Keycode=13 then
         TxtClass.setfocus
    Elseif KeyCode=38 then
         TxtcRdR.setfocus
    End If
End Sub




Private Sub TxtFs_GotFocus()
 ChangeColor TxtFs
End Sub


Private Sub TxtClass_KeyDown(KeyCode As Integer, Shift As Integer)
    If Keycode=13 then
         TxtClass.setfocus
    Elseif KeyCode=38 then
         TxtFs.setfocus
    End If
End Sub




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

If  trim(TxtName)="" then 
           TxtName.Setfocus : Valid=False : Msgbox "Enter "
Elseif  trim(TxtLisName)="" then 
           TxtLisName.Setfocus : Valid=False : Msgbox "Enter "
Elseif  trim(TxtcRdR)="" then 
           TxtcRdR.Setfocus : Valid=False : Msgbox "Enter "
Elseif  trim(TxtFs)="" then 
           TxtFs.Setfocus : Valid=False : Msgbox "Enter "
Elseif  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
             AcCode=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 Ac_Name from Ac_Mst  where Ac_Name like '"& Trim(Searchstring)&"%' order by Ac_Name"
         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, ", Me, MsfList
    FraList.Visible = True
    MsfList.SetFocus
Dim ObjAc As New AcMst
WIth ObjAc
.AcCode=AcCode
.GetAc_Mst
      TxtClass  =.AcClass
      TxtCode  =.AcCode
      TxtcRdR  =.aCcRdR
      TxtFs  =.AcFs
      TxtLisName  =.AcLisName
      TxtName  =.AcName

End With
End sub




Private Sub CmdDelete_Click()
    Work ="D"
    Clear Me
    CurrentControl = 0
    FlexSearch 46, False, ", 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 ObjAc As New AcMst
With ObjAc
     .AcClass = Val(TxtClass)
     .AcCode = trim(TxtCode)
     .aCcRdR = trim(TxtcRdR)
     .AcFs = trim(TxtFs)
     .AcLisName = trim(TxtLisName)
     .AcName = trim(TxtName)

if Work = "A" Then
    .SaveAc_Mst true
Elseif Work = "M" Then
    .SaveAc_Mst 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
