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 TxtLdgrName_KeyDown(KeyCode As Integer, Shift As Integer)
    If Keycode=13 then
         TxtLdgrDisp.setfocus
    End If
End Sub




Private Sub TxtLdgrName_GotFocus()
 ChangeColor TxtLdgrName
End Sub


Private Sub TxtLdgrDisp_KeyDown(KeyCode As Integer, Shift As Integer)
    If Keycode=13 then
         TxtGroup.setfocus
    Elseif KeyCode=38 then
         TxtLdgrName.setfocus
    End If
End Sub




Private Sub TxtLdgrDisp_GotFocus()
 ChangeColor TxtLdgrDisp
End Sub


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




Private Sub TxtGroup_GotFocus()
 ChangeColor TxtGroup
End Sub


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




Private Sub TxtClass_GotFocus()
 ChangeColor TxtClass
End Sub


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




Private Sub TxtCrDr_GotFocus()
 ChangeColor TxtCrDr
End Sub


Private Sub TxtOpBal_KeyDown(KeyCode As Integer, Shift As Integer)
    If Keycode=13 then
         TxtOpBal.setfocus
    Elseif KeyCode=38 then
         TxtCrDr.setfocus
    End If
End Sub




Private Sub TxtOpBal_GotFocus()
 ChangeColor TxtOpBal
End Sub
Function Valid() as boolean
Valid=True

If  trim(TxtLdgrName)="" then 
           TxtLdgrName.Setfocus : Valid=False : Msgbox "Enter "
Elseif  trim(TxtLdgrDisp)="" then 
           TxtLdgrDisp.Setfocus : Valid=False : Msgbox "Enter "
Elseif  trim(TxtGroup)="" then 
           TxtGroup.Setfocus : Valid=False : Msgbox "Enter "
Elseif  trim(TxtClass)="" then 
           TxtClass.Setfocus : Valid=False : Msgbox "Enter "
Elseif  trim(TxtCrDr)="" then 
           TxtCrDr.Setfocus : Valid=False : Msgbox "Enter "
Elseif  trim(TxtOpBal)="" then 
           TxtOpBal.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
      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)
     .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
