473,324 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

custom input mask msgs

I would like to allow the user to enter an input mask for a field and have the appropriate error message display if the citeria isn't met.ie: input mask = 99AA99"A""B"
the message box would then display "formate must be ' 12AB34AB"
or if the input mask was 9A990"C" the message would be "formate must be '1A23C', or ' 1A234C'"
Note: inputask 'A' is any letter Ucase, and 'a' is any letter lCase, I would like to diferenchiant between the two for msg formating
sorry not formated right for tags but don't think they are needed here
thanks for helping
Apr 2 '08 #1
14 4119
ADezii
8,834 Expert 8TB
I would like to allow the user to enter an input mask for a field and have the appropriate error message display if the citeria isn't met.ie: input mask = 99AA99"A""B"
the message box would then display "formate must be ' 12AB34AB"
or if the input mask was 9A990"C" the message would be "formate must be '1A23C', or ' 1A234C'"
Note: inputask 'A' is any letter Ucase, and 'a' is any letter lCase, I would like to diferenchiant between the two for msg formating
sorry not formated right for tags but don't think they are needed here
thanks for helping
Here is the code to replace the Access Standard Error Message for Input Mask Validation Errors with your own. This only applies for a single Field with an Input Mask! If multiple Fields are involved, the code would be different.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Error(DataErr As Integer, Response As Integer)
  2. Const conINPUT_MASK_VIOLATION As Integer = 2279
  3.  
  4. If DataErr = conINPUT_MASK_VIOLATION Then
  5.   MsgBox "Input Mask Violation. Blah...Blah...Blah..."
  6.   Response = acDataErrContinue
  7. End If
  8. End Sub
Apr 2 '08 #2
Thanks for the repy,
but I am already using that code to produce custom input mask messages,
here what I am trying to do, present the user with a form that will allow them to create/edit the input mask and then the error message would automticly modifiy itself to corispond wth the input mask (see OP for examples)
Thanks
Apr 2 '08 #3
ADezii
8,834 Expert 8TB
Thanks for the repy,
but I am already using that code to produce custom input mask messages,
here what I am trying to do, present the user with a form that will allow them to create/edit the input mask and then the error message would automticly modifiy itself to corispond wth the input mask (see OP for examples)
Thanks
It's fairly easy to pro-grammatically modify the Input Mask of a Field via a Form Interface, store the new Mask in a Table with some reference to the associated Field Name, then use a DLookup in an Error Message to properly reference the Mask for a given Field. In my opinion, and I'm sure most, if not all, of the other Experts/Moderators will agree, it would be very unwise to give this capability to a User of your Database.
Apr 3 '08 #4
Scott Price
1,384 Expert 1GB
An input mask exists to restrict and focus the data entry. It exists for data validation. I agree with ADezii. Giving the users the ability to change this on the fly negates the primary purpose for which it exists in the first place!

I would need a very compelling reason before being able to suggest that this is a good idea :-)

Regards,
Scott
Apr 3 '08 #5
missinglinq
3,532 Expert 2GB
I have to agree with ADezii here, allowing end users this kind of design changing ability is just plain wrong! The whole point of using an Input Mask is to insure that entered data is in the correct format. Why would you allow the user to to decide the correct format and why would you allow more than one format?

Linq ;0)>
Apr 3 '08 #6
NeoPa
32,556 Expert Mod 16PB
I can't imagine a situation where it might be appropriate for a user to choose the input mask directly, however, I don't know your situation so I won't be any more definite than that for now.

However, while changing the mask is fairly straightforward, and changing the error message appears also to be simple in itself, creating a message that intelligently matches the mask without simply displaying the mask within it (in other words parsing the mask itself) would be another job again.

IS there a really good reason for this Trevor?
Apr 3 '08 #7
FishVal
2,653 Expert 2GB
Hi, Trevor.

As far as I've understood your intension, you are trying to figure out a logic for validation of input mask string provided by user. Depending on expected "intelligence", the code may be rather sophisticated. I suggest, just for starters, provide user with opportunity to choose from predefined masks only.

Regards,
Fish.
Apr 3 '08 #8
ok, I see most of you say and in most situations I would agree about not allowing users to adjust an input mask, but here is my situation, and don't see much of anyother option other then to have predefind input masks. Anyway the reason behind input mask adjusting by the enduser( is actualy going to be the assingnd Db admin(I have the back end setup with datasheet(false tables) linked to the real tables so I can further controle what is done there.
back to input mask editing is because the input mask is a mask for an individual's ID Number, and since the IDNumber formate may verry(because I'm settiny this DB up so more then one entity may be able to mod it to their needs through an interface). I only know 1 input mask which is ##### or ######
I hope this made my logic of why I would even want to allow the end user this option clearer.
thankyou for all input, I would like feedback on this and suggestions.
Apr 3 '08 #9
NeoPa
32,556 Expert Mod 16PB
  1. Is the InputMask property to be changed in the database or just for the current session?
  2. How many fields are you considering setting this up for?
  3. What logic do you intend to use for parsing the InputMask entered, into your error message?
Apr 3 '08 #10
ADezii
8,834 Expert 8TB
ok, I see most of you say and in most situations I would agree about not allowing users to adjust an input mask, but here is my situation, and don't see much of anyother option other then to have predefind input masks. Anyway the reason behind input mask adjusting by the enduser( is actualy going to be the assingnd Db admin(I have the back end setup with datasheet(false tables) linked to the real tables so I can further controle what is done there.
back to input mask editing is because the input mask is a mask for an individual's ID Number, and since the IDNumber formate may verry(because I'm settiny this DB up so more then one entity may be able to mod it to their needs through an interface). I only know 1 input mask which is ##### or ######
I hope this made my logic of why I would even want to allow the end user this option clearer.
thankyou for all input, I would like feedback on this and suggestions.
  1. I strongly feel that FishVal's approach is the only valid one should you decide to implement this (User selects from a predefined list of Input Masks).
  2. Are the Input Masks to be applied to a Field in a Form or in a Table? If they are defined in a Table, the corresponding Field in a Form will not inherit the Mask.
  3. What is the List of acceptable Input Masks along with their descriptions?
  4. You need Input Mask Validation Errors to correspond to the existing Input Mask at the timer the Error occurs. The Field Names and Masks can be stored internally in a Hidden Table, while the name of the Control for which the Input Mask Error occurred can be retrieved by Screen.ActiveControl.Name.
Apr 3 '08 #11
The input mask is for 1 field the current input mask is 999990 and msg formate should be 12345 or 123456.
this is to be aplied to the field via dlookup and attaching it to a string , the table the value is looked up from is (will be) hidden .
II hope this answers everyones questions
I am using the input mask validation on active screen to produce custom messages..
Apr 4 '08 #12
NeoPa
32,556 Expert Mod 16PB
If you have a table with the acceptable InputMasks held, then you should store the error message in another field of the same table. This will be a far simpler solution than trying to work it out by parsing the InputMask directly.
Apr 4 '08 #13
thank you for the code ADezii
the default input mask validation error is pretty ugly for avg user
you guys rock!
Apr 4 '08 #14
ADezii
8,834 Expert 8TB
The input mask is for 1 field the current input mask is 999990 and msg formate should be 12345 or 123456.
this is to be aplied to the field via dlookup and attaching it to a string , the table the value is looked up from is (will be) hidden .
II hope this answers everyones questions
I am using the input mask validation on active screen to produce custom messages..
The following solution seems to work very well for what you are trying to accomplish:
  1. Create a Table named tblMasks with the following Fields:
    1. [Field_Name] 'will hold the names of all Fields having Input Masks
    2. [Mask] 'the actual Mask itself '999990', etc.
    3. [Error_Msg] 'your Custom Error Message for a specific Field
    4. All Fields are {TEXT} and are 'REQUIRED'
    5. Populate tblMasks
  2. Define your Input Masks for your Form Fields that wish to participate.
  3. Copy and Paste the following code to the Form's Error() Event.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Form_Error(DataErr As Integer, Response As Integer)
    2. Dim varErrMsg As Variant
    3. Dim strFldName As Variant
    4. Dim varInputMask As Variant
    5. Dim strMsg As String
    6. Const conINPUT_MASK_VIOLATION As Integer = 2279
    7.  
    8.  
    9. If DataErr = conINPUT_MASK_VIOLATION Then
    10.   strFldName = Screen.ActiveControl.Name        'Retrieve Field Name
    11.   'Retrieve Custom Error Message
    12.   varErrMsg = DLookup("Error_Msg", "tblMasks", "[Field_Name] = '" & strFldName & "'")
    13.   'Retrieve valid Input Mask information
    14.   varInputMask = DLookup("Mask", "tblMasks", "[Field_Name] = '" & strFldName & "'")
    15.  
    16.     strMsg = "Input Mask Error in [" & strFldName & "]" & vbCrLf & varErrMsg & vbCrLf
    17.     strMsg = strMsg & "Valid Input Mask: " & Nz(varInputMask, "No Valid Input Mask(s) provided")
    18.       MsgBox strMsg, vbExclamation, "Input Mask Violation"
    19.         Response = acDataErrContinue
    20. End If
    21. End Sub
  4. Any questions or problems, give us a call.
Sample OUTPUT (displayed Error Messages):
Expand|Select|Wrap|Line Numbers
  1. Input Mask Error in [txtField1]
  2. Valid entries are 12345 or 123456
  3. Valid Input Mask: 000009
  4.  
  5.  
  6. 'For Controls not listed in tblMasks
  7. Input Mask Error in [cboBlah]
  8.  
  9. Valid Input Mask: No Valid Input Mask(s) provided
  10.  
Apr 4 '08 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Serious_Practitioner | last post by:
Hello, and thank you in advance for your help. Again. I want to enter the month and day portions only of a date into a table field. The idea is that I'll use the information later to generate a...
2
by: johnp | last post by:
Hi, Our Tech department updated users to Office 2003 this week. Now the input mask in one of the applications is showing up as: (###) ###-### The input mask wizard works correctly when I...
3
by: AA Arens | last post by:
When I want the first character of a field to be Uppercased, I need to make an input mask, like >L< followed by ??????? for example. But this mask creates ____ in an unfilled field, which I don't...
6
by: Regnab | last post by:
Morning All, I'm trying to ensure that when the user enters a number on a form, the database automatically leaves a space after the 3rd number. I've tried to do this using input masks, but when...
0
by: SenseiHitokiri | last post by:
I am trying to create a custom textbox that has an input mask to show the text as a phone number. I am very new to this language and trying to figure out how these pages relate. I thought I had...
18
by: louie310 | last post by:
I am working on a Access data base as a school project. The data base has forms with fields that need to be filled out. The forms currently are set up where certain fields that are required have...
3
by: louie310 | last post by:
I finally came up with an answer for creating a custom message if the input mask is violated. In the properties window for the phone field, open the data tab. In the validation rule I typed in the...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.