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

Simulate Keyboard 1

Status
Not open for further replies.

techsponge

Technical User
Feb 8, 2006
37
US
I am developing a program that uses a touch screen.

I have two fields 'UserName' and 'Password' on the login screen.

I have also created individual buttons A-Z for the user to press.

I have been trying to figure out how to get the info into the correct field using the On Click event with no luck?

Something like this:

Private Sub Ctl1_Click()
'If the username has the focus put a 1 in the field
if me.username.hasfocus then
me.username.value & '1'
End if
'If the password has the focus put a 1 in the field
if me.password.hasfocus then
me.password.value & '1'
End if
End Sub


Thanks in advance
 
Have a look at the PreviousControl property:
Screen.PreviousControl.Value = Screen.PreviousControl.Value & '1'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks PH,

I tried the following:

Private Sub Ctl1_Click()
'Put A 1 in the field that has the focus
Screen.PreviousControl.Value = Screen.PreviousControl.Value & 1
End Sub

Works great when the focus is in the username, but when the focus is moved to the password field, it places the '1' in the username field.

Appreciate the help!
 
How are ya techsponge . . .

Have each one of your letter buttons send the approriate character to the following common routine (copy/paste to the forms code module).
Code:
[blue]Private Sub TypeChr(strChr As String)
   Dim Nam As String
   
   Nam = Screen.PreviousControl.Name [green]'get control name[/green]
   Me(Nam) = Me(Nam) & strChr [green]'append character to control[/green]
   Me(Nam).SetFocus [green]'set focus back to control[/green]
   Me(Nam).SelStart = Len(Me(Nam)) [green]'position cursor for next entry[/green]

End Sub[/blue]
Example call for the letter [blue]A[/blue] button:
Code:
[blue]   Call TypeChr("A")[/blue]
. . . have you thought about handling lower/upper case?

Calvin.gif
See Ya! . . . . . .
 
techsponge . . .

You may want to consider setting the [blue]Input Mask[/blue] of your Password field to [blue]PassWord[/blue]! . . . Shows the [blue]*[/blue] instead!

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top