Hi,
have the code below attached to search button but when click nothing happen no error and no search.
here is the code:
thank you
have the code below attached to search button but when click nothing happen no error and no search.
here is the code:
VBA Code:
Private Sub btnSearch_Click()
Dim RecordRow As Long
Dim RecordRange As Range
' Turn off default error handling so Excel does not display
' an error if the record number is not found
On Error Resume Next
' Find the row in the table that the record is in
RecordRow = Application.Match(CLng(txtvendor.Value), Range("DISTRIBUTION_SET_G-L_CODING[Record]"), 0)
' Set RecordRange to the first cell in the found record
Set RecordRange = Range("DISTRIBUTION_SET_G-L_CODING").Cells(1, 1).Offset(RecordRow - 1, 0)
' If an erro has occured i.e the record number was not found
If Err.Number <> 0 Then
ErrorLabel.Visible = True
On Error GoTo 0
Exit Sub
End If
' Turn default error handling back on (Let Excel handle errors from now on)
On Error GoTo 0
' If the code gets to here the record number was found
' Hide the error message 'Not Found'
ErrorLabel.Visible = False
' and populate the form fields with the record's data
txtvendor.Value = RecordRange(1, 1).Offset(0, 1).Value
txtcurrency.Value = RecordRange(1, 1).Offset(0, 1).Value
txtbPO.Value = RecordRange(1, 1).Offset(0, 1).Value
txtapprover.Value = RecordRange(1, 1).Offset(0, 1).Value
txtGLcode.Value = RecordRange(1, 1).Offset(0, 1).Value
txtLineDes.Value = RecordRange(1, 1).Offset(0, 1).Value
txttax.Value = RecordRange(1, 1).Offset(0, 1).Value
txtAccTer.Value = RecordRange(1, 1).Offset(0, 1).Value
txtOrgUnit.Value = RecordRange(1, 1).Offset(0, 1).Value
txt.Value = RecordRange(1, 1).Offset(0, 1).Value
End Sub
thank you