Update:
Update to my own problem. I have created a query with my original query (that strips a full UK postcode down to its first one or two letters) and my table of possible postcode starts. I have asked the query where the abbreviated postcode = a postcode in the table to display the postcode area identity number:
PC3: IIf([PC2]=[Postcode],[Postcode ID],0)
this seems to work until I get a 'data type mismatch in criteria expression' After scratching my head about this for a while (they are both text) I have come to the conclusion it is because there are blank fields in the full postcode field of the database. How would I put an 'catch this out' expression in my original code? Which was:
Function StripPC(PostalCode As String) As String
If Len(PostalCode) >= 2 And Mid(PostalCode, 2, 1) < "a" Then
StripPC = Left(PostalCode, 1)
Else
StripPC = Left(PostalCode, 2)
End If
End Function
Many thanks for all your help
DDiver