Final step in postcode queries! (1 Viewer)

ddiver

Registered User.
Local time
Today, 19:38
Joined
Feb 23, 2005
Messages
28
I have a query that strips the first identifier part of a postcode off the whole postcode. I now need to compare that identifier with a postcode table I have and for it to give me the corresponding area code. ie I have postcode AB456DG my first query strips that to AB and then I want to compare it to AB in my postcode table and for it to tell me that AB is area code 5. Is there a simple way to go about that?
 

ddiver

Registered User.
Local time
Today, 19:38
Joined
Feb 23, 2005
Messages
28
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
 

Users who are viewing this thread

Top Bottom