Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / August 2006

Tip: Looking for answers? Try searching our database.

setfocus doesnt work

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bre-x - 09 Aug 2006 17:48 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
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.