Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

re-assign key jobs in keyboard

Status
Not open for further replies.

Fekri

Programmer
Jan 3, 2004
284
0
0
IR
Hi,

I want to use any code in one of my form to type "000" instead of "0" when I press zero (0)..

example:

normally when I press 1 2 3 0 will type 1230

But I need when I press 1 2 3 0 to be typed 123000

is there any body to help me?

High appreciate
Ali

Thanks & Good Luck
Ali Fekri
 
There are lots of things might go wrong so you whould test this.

I would use code in the after update event of the text box:

Code:
If Not IsNull(Me.txtYourTextBoxName) Then
  If Me.txtYourTextBoxName Mod 100 <> 0 Then
      Me.txtYourTextBoxName = Me.txtYourTextBoxName * 100
   Else
      'do nothing
  End If
End If


Duane
Hook'D on Access
MS Access MVP
 
You may also try KeyPress event:

Code:
If KeyAscii = 48 Then
    Me.txtYourTextBoxName = Me.txtYourTextBoxName & "00"
End If

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
What do you want to happen when you type something like:

1 0 3 0

 
How are ya Fekri.

In the [blue]KeyPress[/blue] event of the control in question, copy/paste the following:

Code:
[blue]   Dim ctl As Control
   
   Set ctl = Me![purple][b]YourControlName[/b][/purple]
   
   If KeyAscii = vbKey0 Then
      ctl.Text = ctl.Text & "00"
      ctl.SelStart = Len(ctl)
   End If
   
   Set ctl = Nothing[/blue]

Also, according to the ops post origination, 1 0 3 0 = 1 000 3 000

[blue]Cheers! ...[/blue]


See Ya . . .

Be sure to see FAQ219-2884 Worthy Reading! [thumbsup2]
Also FAQ181-2886 Worthy Reading! [thumbsup2]
 
To All

Correction: 1 0 3 0 = 10003000



See Ya . . .

Be sure to see FAQ219-2884 Worthy Reading! [thumbsup2]
Also FAQ181-2886 Worthy Reading! [thumbsup2]
 
>according to the ops post

Sure, that's what we may possibly infer from the OP, which is why I asked what the OP wanted to happen as that may not be what they meant to imply.

 
[blue]strongm[/blue]

Agreed! However its all academic as it appears the [blue]op[/blue] won't be back.

See Ya . . .

Be sure to see FAQ219-2884 Worthy Reading! [thumbsup2]
Also FAQ181-2886 Worthy Reading! [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top