If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Dynamic Credit Card Length
I have two objects on a form that I am trying to manipulate. The first is a
combo box to select a credit card type (Mastercard, Visa, Discover, Etc.). The second is a text field to hold the actual credit card number. In order to prevent data entry error, I have put an input mask on the text field of 0000-0000-0000-9999. The last 4 digits are 9s (optional entry) because one of the credit card types has only 12 digits as opposed to 16. However, that would mean that someone could enter a 12 digit number for a card with 16 digits, which is of course not good. Using the above input mask is a very sloppy fix, and doesn't account for all possible entry errors. Is there any way to dynamically change the input mask to adjust for which credit card type is selected? Visa, Mastercard, etc.: 0000-0000-0000-0000 Custom Card: 0000-0000-0000 Thanks, Nick |
#2
|
|||
|
|||
You can change an input mask using VBA. You could do that in the After
Update event of your card type combo box. A trick you might try, if your combo row source is a list, is to add a column to the list that is the input mask for that card: Mastercard;"0000-0000-0000-0000";Visa;"0000-0000-0000-0000";Custom;"0000-0000-0000" Make the column width 0 so the user doesn't see it. Then in the After Update event of the combo: Me.txtCardNumber.InputMask = Me.cboCardType.Column(1) "Tatakau" wrote: I have two objects on a form that I am trying to manipulate. The first is a combo box to select a credit card type (Mastercard, Visa, Discover, Etc.). The second is a text field to hold the actual credit card number. In order to prevent data entry error, I have put an input mask on the text field of 0000-0000-0000-9999. The last 4 digits are 9s (optional entry) because one of the credit card types has only 12 digits as opposed to 16. However, that would mean that someone could enter a 12 digit number for a card with 16 digits, which is of course not good. Using the above input mask is a very sloppy fix, and doesn't account for all possible entry errors. Is there any way to dynamically change the input mask to adjust for which credit card type is selected? Visa, Mastercard, etc.: 0000-0000-0000-0000 Custom Card: 0000-0000-0000 Thanks, Nick |
#3
|
|||
|
|||
Input masks are not very useful.
Use the BeforeUpdate event of the *form* to perform the validation on the Len() of the field. -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Tatakau" wrote in message ... I have two objects on a form that I am trying to manipulate. The first is a combo box to select a credit card type (Mastercard, Visa, Discover, Etc.). The second is a text field to hold the actual credit card number. In order to prevent data entry error, I have put an input mask on the text field of 0000-0000-0000-9999. The last 4 digits are 9s (optional entry) because one of the credit card types has only 12 digits as opposed to 16. However, that would mean that someone could enter a 12 digit number for a card with 16 digits, which is of course not good. Using the above input mask is a very sloppy fix, and doesn't account for all possible entry errors. Is there any way to dynamically change the input mask to adjust for which credit card type is selected? Visa, Mastercard, etc.: 0000-0000-0000-0000 Custom Card: 0000-0000-0000 Thanks, Nick |
#4
|
|||
|
|||
Allen,
Your comment on Input Masks suprises me. In most instances they are not necessary, but for cases like this, phone numbers, or other data that needs to be in a specific format, I find them useful. I would consider this situation the perfect place to use an input mask; otherwise, you would have write code to check the length of the entry against the length required by the card issuer and ensure it is numeric data. You would also have to determine whether any - characters are entered and whether you want to store them in the data base. This very simple input mask resolves those issues. "Allen Browne" wrote: Input masks are not very useful. Use the BeforeUpdate event of the *form* to perform the validation on the Len() of the field. -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Tatakau" wrote in message ... I have two objects on a form that I am trying to manipulate. The first is a combo box to select a credit card type (Mastercard, Visa, Discover, Etc.). The second is a text field to hold the actual credit card number. In order to prevent data entry error, I have put an input mask on the text field of 0000-0000-0000-9999. The last 4 digits are 9s (optional entry) because one of the credit card types has only 12 digits as opposed to 16. However, that would mean that someone could enter a 12 digit number for a card with 16 digits, which is of course not good. Using the above input mask is a very sloppy fix, and doesn't account for all possible entry errors. Is there any way to dynamically change the input mask to adjust for which credit card type is selected? Visa, Mastercard, etc.: 0000-0000-0000-0000 Custom Card: 0000-0000-0000 Thanks, Nick |
#5
|
|||
|
|||
Perfect! I was thinking I'd have to write code like "after update, if
cardtype = Mastercard then inputmask = '0000-0000-0000-0000'"... your solution is much more clever! Thanks! Nick "Klatuu" wrote: You can change an input mask using VBA. You could do that in the After Update event of your card type combo box. A trick you might try, if your combo row source is a list, is to add a column to the list that is the input mask for that card: Mastercard;"0000-0000-0000-0000";Visa;"0000-0000-0000-0000";Custom;"0000-0000-0000" Make the column width 0 so the user doesn't see it. Then in the After Update event of the combo: Me.txtCardNumber.InputMask = Me.cboCardType.Column(1) "Tatakau" wrote: I have two objects on a form that I am trying to manipulate. The first is a combo box to select a credit card type (Mastercard, Visa, Discover, Etc.). The second is a text field to hold the actual credit card number. In order to prevent data entry error, I have put an input mask on the text field of 0000-0000-0000-9999. The last 4 digits are 9s (optional entry) because one of the credit card types has only 12 digits as opposed to 16. However, that would mean that someone could enter a 12 digit number for a card with 16 digits, which is of course not good. Using the above input mask is a very sloppy fix, and doesn't account for all possible entry errors. Is there any way to dynamically change the input mask to adjust for which credit card type is selected? Visa, Mastercard, etc.: 0000-0000-0000-0000 Custom Card: 0000-0000-0000 Thanks, Nick |
#6
|
|||
|
|||
In general, input masks have more downsides than positives, such as the
inability to insert a missed digit. In particular, the number of digits varies beyond the 2 values the OP suggested, e.g. Visa can be 13, Diner can be 14, AmEx can be 15. Further, these could change in the future, so hard-coding rules is not a good idea. A better solution is to create a table of the card types to be handled, and a related table of the prefix ranges for each card, with the number of digits required for the prefix range, and whether to use the checksum algorithm as per: http://www.scriptarchive.com/ccver.html We are well outside the capabilities of an input mask here. -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Klatuu" wrote in message ... Allen, Your comment on Input Masks suprises me. In most instances they are not necessary, but for cases like this, phone numbers, or other data that needs to be in a specific format, I find them useful. I would consider this situation the perfect place to use an input mask; otherwise, you would have write code to check the length of the entry against the length required by the card issuer and ensure it is numeric data. You would also have to determine whether any - characters are entered and whether you want to store them in the data base. This very simple input mask resolves those issues. "Allen Browne" wrote: Input masks are not very useful. Use the BeforeUpdate event of the *form* to perform the validation on the Len() of the field. "Tatakau" wrote in message ... I have two objects on a form that I am trying to manipulate. The first is a combo box to select a credit card type (Mastercard, Visa, Discover, Etc.). The second is a text field to hold the actual credit card number. In order to prevent data entry error, I have put an input mask on the text field of 0000-0000-0000-9999. The last 4 digits are 9s (optional entry) because one of the credit card types has only 12 digits as opposed to 16. However, that would mean that someone could enter a 12 digit number for a card with 16 digits, which is of course not good. Using the above input mask is a very sloppy fix, and doesn't account for all possible entry errors. Is there any way to dynamically change the input mask to adjust for which credit card type is selected? Visa, Mastercard, etc.: 0000-0000-0000-0000 Custom Card: 0000-0000-0000 |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Version 8 Integration for SOP does not pick up the credit card specified in the source field it uses the default credit card against the debtor. | Jen | General Discussion | 1 | September 14th, 2005 03:17 AM |
credit card number security | jeffh | General Discussion | 4 | May 12th, 2005 03:55 AM |
REAL CREDIT CARD NUMBERS HACK!! | Dirk Goldgar | General Discussion | 14 | November 20th, 2004 11:09 AM |
Credit Card Character Count | AL V | Running & Setting Up Queries | 1 | June 30th, 2004 06:48 PM |
Credit Card Number Suppression | Dana | Worksheet Functions | 7 | November 10th, 2003 10:01 PM |