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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

in-form keypad NUMBER pad

Status
Not open for further replies.

696796

Programmer
Aug 3, 2004
218
GB
Hi,

Bit of a tricky one, just wondering how i should approach this. Can a keypad (numbers0-9) be created in a form or as a subform, so that a user can click a button eg button1, and that will put 1 in the text field they are on.

Can this be done/is it difficult to do/any ideas????!!

Thanks for your time,

Regards,

Alex
 
Create 10 buttons

name each text box 1 , 2 3 etc

use this eitheer on the on click of each number button or as a function

Me.MyTextBox = Me.MyTextBox & Screen.ActiveControl.Name


Best wishes

Jimmy

 
Jimmy,

Thanks for your feedback, I'm not quite sure on what is happening. In my head:-

Each button is

btnTextbox1
btnTextbox2 etc...

Then the on-click event

Me.MyTextBox = Me.MyTextBox & Screen.ActiveControl.Name

Not too sure whats happening here. how does this assign a number to the textbox that the curser is in?

Would it be possible for you to explain this furthur, i'm really interested in how this will work as it will make my application complete!

Really apreciate your expertise and knowledge, thanks in advance

Alex
 
Try this...
Create 10 buttons. Name them cmdZero through cmdNine. Define a variable such as strTextbox. In the Got Focus event of each text box that can receive data from the buttons, place this code...
strTextbox = me.TextBoxName

Now create this function...
Private Function FillTextBox(intX as Integer)
Select Case strTextbox
Case "FirstTextboxName":
me.FirstTextboxName = intX
Case "SecondTextboxName":
me.SecondTextboxName = intX
Case ...continue for as many as needed...
End Select
End Function


In the click event of each button...
Call FillTextBox(Number)


Randy
 
Thanks for for feedback guys, i'm trying your method Randy. here's what ive done...


At the top ive declared:-

Dim strTextBox As String

I have this function:-

Code:
Private Function FillTextBox(intX As Integer)
   Select Case strTextBox
      Case "Text78":
         Me.Text78 = intX
      Case "Text80":
         Me.Text80 = intX
     
   End Select
End Function

And this for the On-Click of button 1:-

Code:
Private Sub Command98_Click()
Call FillTextBox(1)
End Sub

And this for the get_focus of textbox (text78)
Code:
Private Sub Text78_GotFocus()
[aqua]strTextBox = Me.Text78[/aqua]
End Sub

i'm getting runtime error 94 - invalid use of null, and it takes me to the above line of code

Can you see what i may have got wrong or what this error means?

Thanks again for your help, its really very much apreciated,

Regards,

Alex

 
Sorry forgot to say i did declare the variable strTextbox as a string and an int and neither worked,

Cheers

Al
 
Looks like randy700's code might work with the following alteration of the

[tt]Private Function FillTextBox(intX as Integer)
me(strTextbox).value = intX ' or perhaps
' me(strTextbox).value = me(strTextbox).value & intX
' to concatinate the text
End Function[/tt]

And the GotFocus event might perhaps look like this:

[tt]Private Sub Text78_GotFocus()
strTextBox = "Text78" ' the name of the control
End Sub[/tt]

Roy-Vidar
 
Change this...
Private Sub Text78_GotFocus()
strTextBox = Me.Text78
End Sub

to this...
Private Sub Text78_GotFocus()
strTextBox = "Text78"
End Sub


Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top