Ignore current InputMask and give default value based on Keypress

Posted on 2005-04-08
Last Modified: 2012-05-05

I have a functional Help Desk Trouble Ticket Database.  This database is not much different than any other technical support desk trouble report database.

I have tickets input into the database with a default mask of "AHRS_EM"00000000;0;#

This gives the tickets a string value of "AHRS_EM00000001", and as normal the number increases sequentially.  

I MUST use the AHRS_EM part of the mask, as the tickets are compared to yet another database and it uses that format.


I have been asked if I can use my database to track non-standard tickets as well.  These tickets will not be counted like normal ones and I must track these separately.  So I decided to do that by having the user input the ticket with a number  starting with a 9 or 8 or 7.   This gives me millions of numbers to use before it might become a problem and I don't anticipate that ever becoming an issue.

So...  A standard ticket would be input with "00000021", "00000022", and so on....
While my (non-standard) tickets would be input with "99999999" or "88888888" or "77777777".  I only evaluate the first number to determine the type.  But the user must input ALL eight numbers in order to meet the criteria of the default mask.

If the first number typed starts with a 9, 8, or 7 then the database will dump the ticket input by the user, but take the first number and then assign a new ticket number based on the last ticket input.   i.e. user inputs 99999999, but the ticket is actually changed to 900000007 because the last ticket in the db is 90000006.


What I would like to do is, when the first number input meets my criteria, 9, 8, 7....
I would like the value automatically set to 77777777, 8888888, or 99999999. Instead of the user having to input the value, simply to meet the mask criteria.

I am trying to do this with the KeyPress and then evaluating the ASCII code so...

If KeyPress =  47 then Me.TT = "AHRS_EM99999999"


this does not change the field and the db still requires the rest of the number.

I have even tried If KeyPress = 47 then Me.TT.InputMask=""
(to eliminate the mask requirement)

But that hasn't work for me either.


Has anyone solved a problem like this before?

Question by:pooky2000
    LVL 17

    Expert Comment

    I hate this kind of problem so just use code to do it.  On the After Update of the input text Box try this:

    Select Case Right(TextBox,1)
       Case = 7
             Me.TT = "AHRS_EM" & YourValue
       Case = 8
             Me.TT = "AHRS_EM" & YourValue
    end select

    And so one.......
    LVL 27

    Expert Comment

    try it On Key up like this:

    if Left(Me.TT.Text, 1)=9 or Left(Me.TT.Text, 1)=8 or Left(Me.TT.Text, 1)=7 then
     me.SPermitEntryDate.InputMask= "00000000;0;#"
    me.SPermitEntryDate.InputMask= "'AHRS_EM'00000000;0;#"

    Author Comment


    I haven't tried this solution yet, but...
    If I implement this solution - wouldn't I still need to populate the entire text box before the AfterUpdate
    would fire (since until the mask is satisfied, the AfterUpdate would error)?

    Author Comment


    SPermitEntryDate - is that a line from another db?  Would I replace that with my textbox name?

    Do I do anything this the KeyPress or DownKey events?

    LVL 17

    Assisted Solution

    Yes, In order to do that you would have to forsake your input mask and probably use a Validation Rule to force correct data entry.  Sorry I left that part out.  Maybe something like =7777777 OR = 8888888 OR =9999999.   Actually you can create fairly complex validation rules to apply to your input text box... Just a thought..
    LVL 27

    Accepted Solution

    I thought SPermitEntryDate was the name of your textbox!
    Yes, replace SPermitEntryDate with you textbox name,
    and remove all the other [Event procedures] for the other keys (KeyPress or DownKey events).


    Author Comment


    Thanks for the assistance.  I actually decided to place a button on the form to calculate the new TT value.

    Why I didn't think of that before, I don't know...  

    But I appreciate all the help.

    Could you tell me why it was important to put the code on the keyup rather than the keydown?
    LVL 27

    Expert Comment

    Very interesting question,

    I have been working on a project where I have a Listbox, and I needed to select multiple entries and be able to double click,
    I had to go through the trial and error to find the best solution,

    Athough you use keys, I used Mouse, which at the end are sort of similar.

    Besides, before I answered you question, I tried it and got the results desired.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now