1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Hi Guest, welcome to the TES Community!

    Connect with like-minded professionals and have your say on the issues that matter to you.

    Don't forget to look at the how to guide.

    Dismiss Notice

Access postcode input mask

Discussion in 'Computing and ICT' started by msa969, Dec 29, 2011.

  1. msa969

    msa969 New commenter

    Hi I am looking through Edexcel strand D unit 2 digital economy.


    The exemplar version on its website shows entering a
    postcode Input Mask with the following


    >LL0 0LL


    This sample work was awarded full marks. The student
    writes "every postcode follows the above format" [sic] but surely
    many postcode do not like London postcodes, here are some: N17 6AD, SW17 7TY,
    N9 0NT.


    How does one go about creating an input mask to
    represent the other format?


    Or would you use the default input
    mask with Access as the sampler student has?</font>
     
  2. Captain Obvious

    Captain Obvious New commenter

    It's been a very long time since I've done input masks, but...
    Perhaps something like:
    L>?0# 0LL
    ?
    The > ensures the following (optional) letter is capital, the # means the number can be a number or a space.
    I think that means two spaces is possible, though.
     
  3. I'm pretty sure I remember input masks not being relevant as they only check data on entry, not when importing (i.e. they won't pick up any errors anyway). Not tested that in anger as far as I can remember though. another thing is that the database must fit the data you are giving it - so as long as all the postcodes in YOUR data match those criteria then no problem.
     
  4. It is not possible to create an Input Mask in Access to correctly allow/disallow all forms of UK Post Codes. (The various formats does not allow it, never mindwhich letters are allowed in which positions).
    The only way to do it properly is to write a VBA routine (or check against a UK Post Code database).
     
  5. DEmsley

    DEmsley New commenter

    The OP asks two questions here. As has been replied the UK postcode system is difficult to get an input mask for, nearest I have managed is something like >LA09/ 09LL
    However for the Unit 2 (and Unit 7) the students need to analyse a GIVEN data set. Therefore the example given works for the limited data set. The shop is a local one and doesn't do nationwide therefore giving something to add in the evaluation as well.
     
  6. v12

    v12

    I just wish I understood the question. LOL
     
  7. UK postcodes do follow a rule:
    • 1 or 2 letters
    • 1 or 2 digits
    • 1 digit
    • 2 letters
    IIRC the built-in mask in Access handles this.
     
  8. Hi there


    You are absolutely right, this input mask will not fit all postcodes. Unfortunately there are some odd postcodes that mean its almost impossible to write an input mask for all postcodes. These are all the formats:

    LN NLL
    LLN NLL
    LNN NLL
    LLNN NLL
    LLNL NLL
    LNL NLL

    So you can see how complex it would be to write an input mask!
    The best 'fit all' solution for most postcodes is:

    >L?0a\ 0LL

    To explain to those who don't understand:

    the > converts all to upper case
    an L means you have to input a letter
    the ? means an optional letter
    the 0 means you have to put a number in
    the a means a number or a digit, optional
    the \ puts a space in

    This should cover all postcodes, but still means you could theoretically input incorrect ones e.g. B123 4QQ. It's really very complicated though ,and even after repeating it for 4 weeks my year 9 and 10 classes didn't really get it.

    This is just the sort of thing that, as a programmer, annoys and frustrates me about the ICT curriculum.

    HTH!

    Ulex

    ETA: Why is none of my formatting included?!
     
  9. JaquesJaquesLiverot

    JaquesJaquesLiverot Established commenter

    I'm afraid that that's not correct - e.g. EC4N 7BU is a valid postcode. There are also other "special" postcodes for things like (ISTR) Girobank.
    The earlier comment was correct - there is no simple rule, and it's not really worth doing using an input mask.
     
  10. That's a problem. I haven't seen those two (awkward) examples. So is Access's built-in mask OK for 99%, but an epic fail for others?
    In projects, I tend to assume the mask works and I don't get picky when marking!
     
  11. I was looking at input masks over the weekend (sad I know), the excercise that I had in front of me covered lots of different kinds of masks for personal detail fields, one of the very few that it didn't look at was the postcode.
    I tend to agree with those that are saying that there is no hard and fast rule for Postcodes in the UK and if required as part of your course then there must be an inbuilt limiter (sample data one would assume)
     

Share This Page