I am trying to create a number keypad on a form that the end user can use to enter data. The end user will be using a tablet while walking in a department and entering data. The below vb code works but does not work when the end user needs to enter data into a sub form on a tab control. A text box on a tab control works, but not the subform. The error msg is RunTime error 2465: MS office cannot find the field 'Text1' referred to in your expression. It works in the form and tab control just not in the subform. What am I missing?
Private Function TypeAlphaNum(strKey As String) As String
Screen.PreviousControl.SetFocus
Me.Controls(Screen.ActiveControl.Name).SelStart = Nz(Len(Me.Controls(Screen.ActiveControl.Name)), 0)
Me.Controls(Screen.ActiveControl.Name).SelLength = 0
Me.Controls(Screen.ActiveControl.Name).Value = Me.Controls(Screen.ActiveControl.Name).Value & strKey
End Function
'this code is used in the number 1 command button
Private Sub cmd1_Click()
TypeAlphaNum "1"
End Sub
Private Function TypeAlphaNum(strKey As String) As String
Screen.PreviousControl.SetFocus
Me.Controls(Screen.ActiveControl.Name).SelStart = Nz(Len(Me.Controls(Screen.ActiveControl.Name)), 0)
Me.Controls(Screen.ActiveControl.Name).SelLength = 0
Me.Controls(Screen.ActiveControl.Name).Value = Me.Controls(Screen.ActiveControl.Name).Value & strKey
End Function
'this code is used in the number 1 command button
Private Sub cmd1_Click()
TypeAlphaNum "1"
End Sub