In my form, I have a MSHFlexGrid (fgdCompany) and a Search button.
What this search button should do is when I enter data into the InputBox, it should search for the entered data and highlight the row that the data was found in green in the MSHFlexGrid. My searching part works great.
But my problem is, if the entered data is not found, I want it to output a MsgBox saying "Record not found".
I can't get the piece of code for that function to work. Can anybody help me to get it right?
Here is the code I am using for the Search button.

Code:
Dim xString As String, xRow As Integer, xNext As Integer
 
  cmdSaveNew.Enabled = False

  x = InputBox("Enter Company Name : ", "Search")
  If x = "" Then
    MsgBox "No data entered"
    Exit Sub
  Else
    txtSearch = x
  End If
      
  xString = txtSearch
  
  For xNext = 0 To fgdCompany.Rows
  fgdCompany.Row = xNext
  If xNext = fgdCompany.Rows Then
  MsgBox "Record not found"
  Exit Sub
  End If
  xRow = fgdCompany.Row
  If xString = fgdCompany.TextMatrix(xRow, 1) Then
  myRow = fgdCompany.Row
  fgdCompany.TopRow = myRow
  fgdCompany.RowSel = myRow
  Me.fgdCompany.Row = myRow
  For j = 0 To Me.fgdCompany.Cols - 1
  Me.fgdCompany.Col = j
  Me.fgdCompany.CellBackColor = vbGreen
  Next j
  Exit For
  End If
  Next xNext