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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input Mask with compulsory brackets

Status
Not open for further replies.

Costefran

Technical User
Jan 2, 2008
197
GB
Can anyone help again

I would like to have an input mask for a control that requires both optional and compulsory characters as follows

The first Characters are optional and can be as many as the user wants and anything such as numbers, caps etc and the last 6 characters are compulsory and must contain opening and closing brackets containing 4 capital letters

So it goes someting like this

The Tower of London is optional and then (TTOL) is compulsory

and it would read as;

The Tower of London (TTOL)

Many thanks again
 
from the help information

Character Description
0 Digit (0 to 9, entry required, plus [+] and minus [–] signs not allowed).
9 Digit or space (entry not required, plus and minus signs not allowed).
# Digit or space (entry not required; spaces are displayed as blanks while in Edit mode, but blanks are removed when data is saved; plus and minus signs allowed).
L Letter (A to Z, entry required).
? Letter (A to Z, entry optional).
A Letter or digit (entry required).
a Letter or digit (entry optional).
& Any character or a space (entry required).
C Any character or a space (entry optional).
. , : ; - / Decimal placeholder and thousand, date, and time separators. (The actual character used depends on the settings in the Regional Settings Properties dialog box in Windows Control Panel).

> Causes all characters to be converted to uppercase.

\ Causes the character that follows to be displayed as the literal character (for example, \A is displayed as just A).



Ian Mayor (UK)
Program Error
9 times out of 10 I know what I'm talking about. This must be my tenth reply.
 
So somehow Access knows the user typed in, optionally, none or 1 to 249 characters and then apply the input mask.
Wouldn't it be simpler to have two fields something like Name and Abbr.? Then the input mask for Abbr would be \(>LLLL\)
By the way, they're not brackets. They're open and close parens. [ ] those are brackets.
 
Many thanks

Have considered two controls but ideally need to keep in one control

guess I'll have to go back to the drawing board as access needs to know when the user has finished entering optional text and then has to enter parenthesis

 
I would advise you take Fneilly's suggestion about breaking up the data into two fields, keeping it in one breaks normalization rules (and I guarantee you it will give you headaches in the future).

Your database should be designed on principles of relational design, not on how controls look on your UI.

 
You could use code to take what the user types in, parse the last 4 characters - use the right function - then format them.
However, consider normalization. What happens if sometimes in the future you want to know all the abbr that are the same? If the name and abbr are in one field, then again you'll have to use code to extract the last characters. In a separate field, you just run a query. But, it's your call you'll have to live with.
 
To All

Have taken and used the recommendation of splitting the controls and it works!!!

Many thanks to all for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top