How to make a Number pad

P

pokdbz

I need to make a number pad on screen. I want to have a person click on the
buttons to enter a SSN. What is the best way to get this information into a
field to save it. Also I wanted to add a backspace so if there is a mistake
they can delete something. Any suggestions?
 
J

Jeff Boyce

Why? Are your users more likely to want to mouse around to each button,
then click, rather than simply type the numbers into a field?

You might try searching at Google.com or at mvps.org/access to see if folks
have already created a numeric keypad form/control...

Good luck

Jeff Boyce
<Access MVP>
 
P

pokdbz

Going to use a touch screen with access.

Jeff Boyce said:
Why? Are your users more likely to want to mouse around to each button,
then click, rather than simply type the numbers into a field?

You might try searching at Google.com or at mvps.org/access to see if folks
have already created a numeric keypad form/control...

Good luck

Jeff Boyce
<Access MVP>
 
R

Roger Carlson

I've created a small sample database called "NumberPad.mdb" and placed it on
my website (www.rogersaccesslibrary.com). You can download it from there if
you like.

Basically, do this: Create your buttons and name them cmd1 through cmd0
plus another called cmdBksp. Also, create a textbox for your SS number and
add an InputMask that does not save the dashes.

Now add the following code behind the form:
'-------------
Sub AddDigit(NewDigit As String)
If Len(Me.SSN & NewDigit) <= 9 Then
Me.SSN = Me.SSN & NewDigit
End If
End Sub
'-------------

Private Sub cmdBksp_Click()
On Error GoTo Err_cmdBksp_Click
If Len(Me.SSN) - 1 < 1 Then
SSN = Null
Else
Me.SSN = Left(Me.SSN, Len(Me.SSN) - 1)
End If
Exit_cmdBksp_Click:
Exit Sub
Err_cmdBksp_Click:
MsgBox Err.Description
Resume Exit_cmdBksp_Click
End Sub

'-------------
Private Sub cmd1_Click()
On Error GoTo Err_cmd1_Click
Call AddDigit("1")
Exit_cmd1_Click:
Exit Sub
Err_cmd1_Click:
MsgBox Err.Description
Resume Exit_cmd1_Click
End Sub
'-------------

Repeat the code for each of the other buttons based on cmd1, but replace
it's number.

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
J

Jeff Boyce

Hmmm? A "touch screen"... sounds like a marvelous invention. When will
they be available <G>?

Jeff
 
P

pokdbz

Thanks that helped me out. Got it working except for if there is nothing in
the text box and you hit the backspace. If you do that it goes to the system
generated error. Says "invalid use of null". I tried to put this in but it
skipped right over it and goes to the invalid

If Len(Me.SSN) - 1 < 1 Then
SSN = Null
Else
If Me.SSN = Null Then
MsgBox ("Please enter your Social Security Number")
Else
Me.SSN = Left(Me.SSN, Len(Me.SSN) - 1)
End If
End If
 
M

Mr B

If you are interested, I have another version. Mine works as a popup form
with backspace and Ok and Cacel buttons. I do not have a location where I can
post it, but if you would like to send me an email, I will be happy to send
you a copy. Just remove the removethis from this email address:
[email protected]
 
Top