Private Sub cmdSrchUsingMidFunction_Click()
On Error GoTo Err_cmdSrchUsingMidFunction_Click
Dim strCriteria As String
Dim strCompany As String
Dim strLeft As String
Dim varMid As Variant
Dim strRight As String
Dim intLen As Integer
Dim intChar As Integer
strCompany =
InputBox("Enter Company Name to Search for....")
If strCompany = "" Then
Exit Sub
End If
intLen = Len(strCompany)
intChar = InS
r(1, strCompany, "#", 1)
If intChar > 0 Then
strLeft = Left(strCompany, (intChar - 1))
strRight = _
Right(strCompany, (intLen - intChar))
varMid = Mid(strCompany, intChar, 1)
strCriteria = strLeft & "[" & varMid & "]" & _
strRight
GoTo NumberSignCriteria
Else
strCriteria = strCompany
End If
DoCmd.GoToControl "CompanyName"
DoCmd.FindRecord strCriteria, , , , True
GoTo Exit_cmdSrchUsingMidFunction_Click
NumberSignCriteria:
DoCmd.GoToControl "CompanyName"
DoCmd.FindRecord strCriteria, , , , True
Exit_cmdSrchUsingMidFunction_Click:
Exit Sub
Err_cmdSrchUsingMidFunction_Click:
MsgBox Err.Description
Resume Exit_cmdSrchUsingMidFunction_Click
End Sub
|