I would edit the function to use the InStr function properly:
Code:
Public Function qryPwrPL(keyEquipUp As Long) As String
Dim strSQL As String
Dim QD As QueryDef
Dim Db As DAO.Database
Dim rs As DAO.Recordset
Dim PreviousKey As Long
Dim PowerPanel As String
'KeyEquipUp = 10081836
Set Db = CurrentDb
PreviousKey = keyEquipUp
strSQL = ""
strSQL = "qryPwrPL"
Set QD = Db.QueryDefs(strSQL)
QD.Parameters("ParamKeyEquipUp") = keyEquipUp
Set rs = QD.OpenRecordset
If InStr(rs!strFPN, "PWR-PL-") > 0 Then
'Found the Power Panel Name so return it.
PowerPanel = rs!strFPN ' PreviousKey "PWR-PL-0082"
qryPwrPL = PowerPanel
Exit Function
Else
If IsNull(rs!keyEquipUp) Then
qryPwrPL = "0"
Exit Function
Else
' Keeps searching until we find the PowerPnael Name
PowerPanel = qryPwrPL(rs!keyEquipUp)
End If
End If
End Function
Also not quite sure about your data, does the query (qryPwrPL) return multiple records for the key? Why use function and not simply a dlookup?
Cheers,