VERSION 5.00
Begin VB.Form C_a_search 
   ClientHeight    =   1635
   ClientLeft      =   2130
   ClientTop       =   5295
   ClientWidth     =   5760
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   1635
   ScaleWidth      =   5760
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton cmd_cancel 
      Caption         =   "Cancel"
      Height          =   372
      Left            =   4320
      TabIndex        =   3
      Top             =   840
      Width           =   1212
   End
   Begin VB.CommandButton cmd_next 
      Caption         =   "Find Next"
      Default         =   -1  'True
      Height          =   372
      Left            =   4320
      TabIndex        =   2
      Top             =   240
      Width           =   1212
   End
   Begin VB.TextBox txt_search 
      ForeColor       =   &H00000000&
      Height          =   288
      Left            =   1320
      MaxLength       =   40
      TabIndex        =   0
      Top             =   480
      Width           =   2772
   End
   Begin VB.Label lbl 
      Height          =   252
      Left            =   240
      TabIndex        =   1
      Top             =   480
      Width           =   972
   End
End
Attribute VB_Name = "C_a_search"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim mi_NbRows As Integer
Dim mi_NbCols As Integer

Dim X As Integer, y As Integer, z As Integer
Dim toprow_max As Integer
Dim prv_y As Integer, prv_x As Integer
Dim find_ok As Boolean

Private Sub cmd_Cancel_Click()
Unload Me
End Sub

Private Sub cmd_next_Click()

On Error GoTo suite

If txt_search = "" Then
  Exit Sub
Else
  For y = prv_y To (mi_NbRows - 1)
    C_audit.grid.Row = y
    For X = prv_x To (mi_NbCols - 1)
      C_audit.grid.Col = X
      z = InStr(1, C_audit.grid.Text, txt_search, 1)
      If z <> 0 Then
        find_ok = -1
        C_audit.grid.Col = X
        C_audit.grid.Row = y
'        C_audit.grid.SelStartRow = y
'        C_audit.grid.SelEndRow = y
'        C_audit.grid.SelStartCol = X
'        C_audit.grid.SelEndCol = X
'        C_audit.grid.HighLight = -1
        GoTo fin
      End If
    Next
    prv_x = 0
  Next
  If find_ok = 0 Then
    SendMessage 10, "Cannot find matching data", gut_LangLogin.Code
    MouseOn
  End If
  Unload Me
  Exit Sub
End If

fin:
prv_x = X + 1
If prv_x > (mi_NbCols - 1) Then
  prv_x = 0
  prv_y = y + 1
Else
  prv_y = y
End If
'Last record detected
If prv_y = (mi_NbRows) And prv_x = (mi_NbCols) Then
  Unload Me
  Exit Sub
End If
If prv_y > (mi_NbRows) Or y > (mi_NbRows) Then
  Unload Me
  Exit Sub
End If
If y < toprow_max Then
  C_audit.grid.TopRow = y
Else
  C_audit.grid.TopRow = toprow_max
End If
Exit Sub

suite:
StdError
End Sub

Private Sub Form_Load()

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

find_ok = 0
mi_NbRows = C_audit.grid.Rows
mi_NbCols = C_audit.grid.Cols
prv_y = 1
toprow_max = mi_NbRows - 19
If toprow_max < 1 Then
  toprow_max = 1
End If

Caption = gs_TitleSearch
lbl.Caption = gs_CriteriaSearch
cmd_next.Caption = gs_NextSearch
cmd_cancel.Caption = gs_CancelSearch

End Sub

