I have these codes that validate the data entry:
Private Sub txtModel_Change()
With txtModel
If Len(.Text) = .MaxLength Then
SendKeys "{tab}"
'txtOwning.setfocus
End If
End With
Private Sub txtModel_Validate(Cancel As Boolean)
With txtModel
If Not (.Text = ""
Then
strCriteria = "select model from valmod where model = '" & .Text & "'"
boolEntry = valEntry(.Text, .TabIndex)
If boolEntry = True Then
.Text = UCase(.Text)
Cancel = False
'txtOwning.SetFocus
Else
MsgBox ("Invalid Model Number. Right-click mouse to view list."
, vbExclamation, "Validation"
Cancel = True
End If
End If
If Cancel = True Then
.SelStart = 0
.SelLength = .MaxLength
End If
End With
End Sub
I believe that the sendkeys "{tab}" would trigger the validation, but after validating, the cursor doesnt't go to the next textbox(txtOwning) but to the one after. If I hard-code the next textbox to have the focus in txtModel_change, the validation doesn't get executed and when I hard-code it on txtModel_validate, the cursor still goes to the textbox after the txtowning.
Any help will be greatly appreciated.
Private Sub txtModel_Change()
With txtModel
If Len(.Text) = .MaxLength Then
SendKeys "{tab}"
'txtOwning.setfocus
End If
End With
Private Sub txtModel_Validate(Cancel As Boolean)
With txtModel
If Not (.Text = ""
strCriteria = "select model from valmod where model = '" & .Text & "'"
boolEntry = valEntry(.Text, .TabIndex)
If boolEntry = True Then
.Text = UCase(.Text)
Cancel = False
'txtOwning.SetFocus
Else
MsgBox ("Invalid Model Number. Right-click mouse to view list."
Cancel = True
End If
End If
If Cancel = True Then
.SelStart = 0
.SelLength = .MaxLength
End If
End With
End Sub
I believe that the sendkeys "{tab}" would trigger the validation, but after validating, the cursor doesnt't go to the next textbox(txtOwning) but to the one after. If I hard-code the next textbox to have the focus in txtModel_change, the validation doesn't get executed and when I hard-code it on txtModel_validate, the cursor still goes to the textbox after the txtowning.
Any help will be greatly appreciated.