I have a number of names and Ids in a table (TblTransactions) and a subset of these in another table (TblSubset). The values in tblSubset are unique. I’ve written a function for a field in a query that I want to populate for each row from tblTransactions with a ‘Yes’ if the name from tblTransactions also occurs in tblSubset and a ‘No’ if it doesn’t. There is a one to many join between the two tables. The code I am using is below.
When I run the query I get a message ‘Data type mismatch in criteria expression’.
If I replace the one-to many join by a one to one join the function works but then I only get the rows common to both tables instead of all the rows in TblTransactions.
If I set up the query, however, with an IIF statement, as below, it works fine.
)
Can anyone tell me how I should be writing the function?
Thanks in advance for any help you can offer.
Code:
Public Function FindMatch(Id1 As String, Id2 As String) As String
If Id1 = Id2 Then
FindMatch = "Yes"
Else: FindMatch = "No"
End If
End Function
If I replace the one-to many join by a one to one join the function works but then I only get the rows common to both tables instead of all the rows in TblTransactions.
If I set up the query, however, with an IIF statement, as below, it works fine.
Code:
Output1: IIf([Id1]=[Id2],"Yes","No"
Can anyone tell me how I should be writing the function?
Thanks in advance for any help you can offer.