Domanda

I have been searching around for a way to do this but I am finding it hard :(

I am very very very new to VBA (In fact, I have not used it) but I am determined !

What I want to do is validate a postcode so that it formats it and checks it. I have tried Input mask and validation, but this are not perfect. So I have turned to VBA.

I have found examples of code, and put them into VBA, but I can't get it to do anything :(

It needs to work with these postcodes ...

A9 9AA

A9A 9AA

A99 9AA

AA9 9AA

AA9A 9AA

AA99 9AA

If anyone could help it would be great. But what would be best if someone could give me a database with the validator in, so I could see it in action and learn. But anything would be good. Just how to make it work would be good :) . What I have done is copy and pasted the code Here into a module and hoped for the best, but nothing happened ?

So any help would be good.

Thank you

È stato utile?

Soluzione

You can use the suggestion of downloading all the UK Post Codes to your database. However, you'll have to stay on top of it as new codes are added later. I'm sure there's an automatic free service out there that will do this for you, but that would be very advanced programming for you.

If you want to just validate the pattern, I found this example. It will not only validate the pattern, but also correct for common typo errors.

If you do use this code, you'll still have to call it at the correct time. That could be when the user leaves the textbox after entering the code, or when they are trying to save the record, or move to another record (automatic save).

Good luck

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top