Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable Post Code select

Status
Not open for further replies.

sbamforth

Technical User
Jan 20, 2004
3
GB

I am trying to select using the prefix of a post code to show all clients within a certain area. I'm using the startswith function to select the prefix of a post code eg HP2. My problem is that this includes HP20, HP21 etc when all i want is HP2. I've noticed elsewhere on this forum how to do this for just one postcode, i need this to run for potentially any postcode though, any suggestions .. ?

 
Left({PostCode},3)="HP2" should solve your immediate problem.

Add a parameter field to your report and modify this formula to look at the parameter field rather than the hard coded value, and you should have a solution to the rest of the problem.

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
I'm not familiar with your post codes, but I think you could use a formula like the following, adjusting the number of zeros to match the maximum number of digits on the right, as long as it always starts with two letters:

left({table.postcode},2)+totext(val(mid({table.postcode},3)),"00")

If the number of initial letters can vary, please provide a sample of post codes that includes all variations.

-LB
 
Thanks for your help guys, its working like a dream now !

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top