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!

keypad on form for entering data - not working with subform

Status
Not open for further replies.

wz

Programmer
Feb 16, 2001
88
0
0
US
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
 
Subforms need to be referred to by name.
Forms![MainFormName]![SubFormName].Form![TextBoxName]
TextBoxName could also be a function but then it would be .[TextBoxName]

I hope that helps.
 
Thank you for your reply but I'm looking for a generic way to do this since I'm unable to hard code every single control...this is why I'm using .activecontrol
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top