I have this code on a text box control (tfind) How come the focus does not
go back to it? It goes to the next control
There is something wrong with my code, but i cannt see it.
Thnks
Private Sub tfind_LostFocus()
Dim sqlstring As String, mymsg As String
If IsNull(Me.tfind) = True Then
Exit Sub
End If
Me.Mainsub.SourceObject = "Blank"
sqlstring = "SELECT count(*) as CC FROM BKARINV WHERE BKAR_INV_SONUM = " &
Me.tfind
CurrentDb.QueryDefs("DBA").SQL = sqlstring
If DLookup("[CC]", "DBA") = 0 Then
mymsg = "Sales Order: " & Me.tfind & " is not on DBA."
Responce = MsgBox(mymsg, vbCritical, " UMC")
Me.tfind.SetFocus
Exit Sub
End If
End Sub
RuralGuy - 09 Aug 2006 18:19 GMT
>I have this code on a text box control (tfind) How come the focus does not
>go back to it? It goes to the next control
[quoted text clipped - 19 lines]
>End If
>End Sub
Validation of entries in controls is usually done in the BeforeUpdate event and
Cancel=True is used to hold the focus in the current event.
_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
Bre-x - 09 Aug 2006 19:01 GMT
That explained it!!
To make it work I had to bound the form and the control. ......That create
another set of problems.
Thanks for your help, now the focus stays where i want it.
Regards,
Bre-x
>>I have this code on a text box control (tfind) How come the focus does not
>>go back to it? It goes to the next control
[quoted text clipped - 26 lines]
> hth - RuralGuy (RG for short)
> Please post to the NewsGroup so all may benefit.