FarleySoftware
Programmer
I have an ADODB recordset that may contain multiple records.
If it contains multiple records, I want to filter the results further, by selecting records where the TranslationDescription field ends with the string value strShift.
Here's my code:
When the filter is applied, I get an error 3001 ("Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.")
I'm sure I'm overlooking something minor yet vexing.
Thanks in advance for taking a look.
If it contains multiple records, I want to filter the results further, by selecting records where the TranslationDescription field ends with the string value strShift.
Here's my code:
Code:
Private Function GetTranslation(strCode As String, _
strShift As String) As Long
Dim rst As New ADODB.Recordset
Dim strSQL As String
Dim strFilter as String
' Find matching record in translation table
strSQL = "SELECT TranslationCode, " _
& "TranslationDescription " _
& "FROM tblTranslation " _
& "WHERE TranslationInternalCode = '" & strCode & "' "
rst.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
' Return matching record; shows as 0 if not found
Select Case rst.RecordCount
Case Is = 1
GetTranslation = CLng(rst!TranslationCode)
Case Is > 1
strFilter = "TranslationDescription LIKE '%" & strShift & "'"
rst.Filter = strFilter ' <-- Error happens on this line
If rst.Recordcount = 1 Then
GetTranslation = CLng(rst!TranslationCode)
Else
GetTranslation = 0
End If
Case Else
GetTranslation = 0
End Select
Set rst = Nothing
End Function
When the filter is applied, I get an error 3001 ("Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.")
I'm sure I'm overlooking something minor yet vexing.
Thanks in advance for taking a look.