I have a table with an ID number which has a special format as follow: 2500-001
By default the number format does not accept dash(-) in the middle of number and I can not make it a Text field as I need this ID as the Primary Key.
Would you please tell me if there is anyway to achieve this in Design View?
Thank you in advance
Use a text box input mask.
You can specify whether or not the dash is included in the data. See here for more information about input masks:
The three parts of an input mask
Input masks are made up one mandatory
part and two optional parts, and each part is separated by a
semicolon. The purpose of each part is as follows:
The first part is mandatory. It includes the mask characters or string
(series of characters) along with placeholders and literal data such
as, parentheses, periods, and hyphens.
The second part is optional and
refers to the embedded mask characters and how they are stored within
the field. If the second part is set to 0, the characters are stored
with the data, and if it is set to 1, the characters are only
displayed and not stored. Setting the second part to 1 can save
database storage space.
The third part of the input mask is also
optional and indicates a single character or space that is used as a
placeholder. By default, Access uses the underscore (_). If you want
to use another character, enter it in the third part of your mask.
Related
I want to create a pattern for an HTML input field that needs to have at least 10 numbers in it and may also have spaces and a plus sign on top of that, but it's not required.
It's important that numbers and spaces can be mixed though. Also, the whole field can only have 17 characters all in all.
I'm not sure if it's even possible. I started doing something like that:
pattern="[0-9+\s]{10,17}*"
But like this, it's not guaranteed that there are at least 10 numbers.
Thanks in advance! Hope the question doesn't exist already, I looked but couldn't find it.
You can use
pattern="(?:[+\s]*\d){10,17}[+\s]*"
The regex matches
(?:[+\s]*\d){10,17} - ten to seveteen occurrences of zero or more + or whitespaces and then a digit
[+\s]* - zero or more + or whitespaces.
Note the pattern is anchored by default (it is wrapped with ^(?: and )$), so nothing else is allowed.
As a user is typing their new password, I want them to be able to see if their password meets the requirements or not. I have a Regex pattern set up inside the input tag, and if the requirements aren't met, the input box is outlined in red and the form can't be submitted. This looks like:
<input type="password" pattern="((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.[!###$%&?]).{8,32})" placeholder="Password" required />
I adapted that pattern from here. I have it so that the user's password must contain 8-32 characters, one uppercase letter, one lowercase letter, one special character (!##$%&?), and one number, and that works fine. However, I also want to exclude some special characters from the input, for example, the semicolon (;). I have tried adding (?!.[;]) like so:
((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.[!###$%&?])(?!.[;]).{8,32})
This breaks the entire pattern, though. Could someone explain what I am doing wrong and how I can fix it? Or would it be better to do this manually by using a Javascript listener to check if the password meets the requirements each time the user does a keypress?
Try with:
((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!###$%&?])(?!.*[;]).{8,32})
Fine-tunings from your regex:
Added back an asterisk * to the positive lookahead for symbols list [!###$%&?]
Added back an asterisk * to the negative lookahead for symbol [;]
You need an asterisk * after the dot . in order to allow matching of multiple characters (by *) for any character (by .). Otherwise, your regex allows only ONE single character before the symbols to include and exclude.
Is there a way to set an input mask or validation rule in MS Access 2016 so that certain elements are optional?
Employee Reference can be in a number of formats: starts with a character E follow by space and 10 numbers. These will be mandatory and then the last character should be optional.
So, is there a way for me to set the input mask so that the first letter, space and 10 numbers are mandatory and last character is optional?
For example:
E <space> 100234240 <optional Letter>
E 100234240A
or
E 100234240
As described in the official documentation, you will require the following input mask characters to achieve your desired result:
0 User must enter a digit (0 to 9).
a User can enter a letter or a digit.
"" Characters enclosed in double quotation marks will be displayed literally.
You may also wish to use:
> Converts all characters that follow to uppercase.
Given the above, I might suggest the following input mask:
>"E "0000000000a;0
Here, the 0 following the semi-colon in the input mask indicates that the mask characters will be stored along with the data (i.e. the "E " will also be stored).
And if you want a different placeholder character, perhaps something like:
>"E "0000000000a;0;#
I have a database containing data like [1][24], [2], [45], [36][23][14]. The numbers in square brackets have 2 digits at most. I have trouble with square brackets. For example when I write the query using LIKE and search for '?3?' I want it to find data containing [3]. However it omits the square brackets and returns [36][23][14] since it contains '23]1'. I also tried queries like "["&'3'&"]" and '[[3]]' but it didn't work.
You need to escape the first square bracket, it is a special character:
WHERE SomeText Like "*[[]3]*"
Even though the second square bracket is also a special character, it does not need to be escaped.
If you simply want any single number in square brackets contained in a field / column:
WHERE SomeText Like "*[[]#]*"
If I embed XML into a TEXT column in MySQL, will it retain the spacing/indentation of the XML blob? Will I need to fix the markup when I retrieve it so it isn't just a long string?
Per the docs, the text you put in will stay untouched (except for possible truncation if you try to put more text in than the datatype can accept). Indeed, there are few differences with VARCHAR: no DEFAULT value, and, if you put an index on a TEXT column, you must specify the prefix length, which is only optional for VARCHAR.