I have this bit ofcode to force alpha characters to ucase. It works a few times then gives me a 2185 error "can't reference an object unless it has the focus." I have the code in the Key-Up event and have tried it in the Change event with the same results.
Private Sub txtSearchPN_KeyUp(KeyCode As Integer, Shift As Integer)
Dim intStrLen As Integer
Dim strNewValue As String
'match text and value
Me.cmdClose.SetFocus
Me.txtSearchPN.SetFocus
If Me.txtSearchPN.Text = "" Then
Me.txtSearchPN.Value = ""
Exit Sub
End If
If IsNumeric(Right(Me.txtSearchPN.Text, 1)) = True Then
Else
intStrLen = 1
Do Until intStrLen = Len(Me.txtSearchPN.Text) + 1
If IsNumeric(Mid(Me.txtSearchPN.Text, intStrLen, 1)) = True Then
strNewValue = strNewValue + Mid(Me.txtSearchPN.Text, intStrLen, 1)
Else
strNewValue = strNewValue + StrConv(Mid(Me.txtSearchPN.Text, intStrLen, 1), vbUpperCase)
End If
intStrLen = intStrLen + 1
Loop
Me.txtSearchPN.Value = Left(strNewValue, 10)
Me.txtSearchPN.SelStart = Len(Me.txtSearchPN.Value) + 1
End If
If Len(Me.txtSearchPN.Value) >= 8 Then
ChangeRecordsource
Me.txtSearchPN.SetFocus
Me.txtSearchPN.SelStart = Len(Me.txtSearchPN.Value) + 1
End If
End Sub
The .text value does not match the .value value at this point. Am I doing it in the wrong event or ????
Thanks for looking. Access 2010 in 2007 mode, XP SP3.
Joel
Private Sub txtSearchPN_KeyUp(KeyCode As Integer, Shift As Integer)
Dim intStrLen As Integer
Dim strNewValue As String
'match text and value
Me.cmdClose.SetFocus
Me.txtSearchPN.SetFocus
If Me.txtSearchPN.Text = "" Then
Me.txtSearchPN.Value = ""
Exit Sub
End If
If IsNumeric(Right(Me.txtSearchPN.Text, 1)) = True Then
Else
intStrLen = 1
Do Until intStrLen = Len(Me.txtSearchPN.Text) + 1
If IsNumeric(Mid(Me.txtSearchPN.Text, intStrLen, 1)) = True Then
strNewValue = strNewValue + Mid(Me.txtSearchPN.Text, intStrLen, 1)
Else
strNewValue = strNewValue + StrConv(Mid(Me.txtSearchPN.Text, intStrLen, 1), vbUpperCase)
End If
intStrLen = intStrLen + 1
Loop
Me.txtSearchPN.Value = Left(strNewValue, 10)
Me.txtSearchPN.SelStart = Len(Me.txtSearchPN.Value) + 1
End If
If Len(Me.txtSearchPN.Value) >= 8 Then
ChangeRecordsource
Me.txtSearchPN.SetFocus
Me.txtSearchPN.SelStart = Len(Me.txtSearchPN.Value) + 1
End If
End Sub
The .text value does not match the .value value at this point. Am I doing it in the wrong event or ????
Thanks for looking. Access 2010 in 2007 mode, XP SP3.
Joel