Ignore current InputMask and give default value based on Keypress

Posted on 2005-04-08
Medium Priority
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
  • 3
  • 3
  • 2
LVL 17

Expert Comment

ID: 13739560
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

ID: 13740452
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

ID: 13741575

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)?
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.


Author Comment

ID: 13741585

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

Arji earned 800 total points
ID: 13742122
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

jjafferr earned 1200 total points
ID: 13742769
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

ID: 13754593

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

ID: 13754715
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.


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

839 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