验证Access中的邮政编码? [英] Validate Postcode in Access?

查看:113
本文介绍了验证Access中的邮政编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找实现此目的的方法,但是我发现它很困难:(

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

我对VBA非常陌生(实际上,我还没有使用过它),但我下定了决心!

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

我想做的是验证邮政编码,以便对其进行格式化并检查.我已经尝试了输入掩码和验证,但这并不完美.所以我转向了VBA.

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.

我找到了代码示例,并将其放入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.

谢谢

推荐答案

您可以使用将所有英国邮政编码下载到数据库的建议.但是,随着以后添加新代码,您将不得不紧随其后.我敢肯定有一个自动的免费服务可以为您做到这一点,但这对您来说是非常高级的编程.

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).

祝你好运

这篇关于验证Access中的邮政编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆