I have the following function in an MS Access Database
Public Function Get_Status(ByRef str_Status As String) As Long
Dim rs As New ADODB.Recordset, strsql
Select Case str_Status
Case Is = "OPTED-OUT", Is = "OPT-OUT"
str_Status = "OPTED OUT"
Case Is = "TERMED."
str_Status = "TERMED"
End Select
strsql = "Select DISPOSITIONID From tbl_Dispositions Where DISPOSITION_DESC Like ""*" & str_Status & "*"""
rs.Open strsql, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
If Not rs.EOF Then
Get_Status = rs!DispositionID
End If
rs.Close
Set rs = Nothing
End Function
The purpose of this function is that we are taking an Excel Spreadsheet and converting it to an Access DB. One of the Fields in the spreadsheet is Disposition which is in Text. I've created a Dispositions Table with a PK and Description. When the spreadsheet is converted to a table the Status Field is updated with the DispositionID. The SQL that is built above ends up looking like
Select DispositionID From Dispositions Where Dispositions_Desc Like "*Termed*"
If I copy that SQL into a Query I get the result 1 row with DispositionID = 2 which is correct. However when I call the function from my update Query I get 0 rows. Same query. 1 from the Query Designer which gives the correct value and 1 in code which doesn't.
Any Ideas why?
This is access 2010 by the way