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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SetFocus on control after Click

Status
Not open for further replies.

mraetrudeaujr

Technical User
Dec 20, 2004
137
US
I tried searching this forum for information on having the focus go back to the first 'control' textbox of the tab order, but I couldn't find anything that quite addressed this problem. What I need is this: to be able to open up my form, have the focus on my PRSLOG number, then if I hit the command button that takes me to the "last record" I want it to go back to this control --- not stay on the command button. This would be very useful for any command button that I use throughout my databases. Any code or suggestions out there that I could use?
 
Hi
Maybe:
Code:
    On Error Resume Next
    For Each ctl In Me.Controls
        If ctl.TabIndex = 0 Then ctl.SetFocus
        Exit For
    Next
 
I tried your code snippet but got an error "Variable not defined" based on ctl. Do I need to dim it at set first?
If so as an object or is the ctl misspelled?

Please advise.

Steve G.
 
Dim ctl As Access.Control

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top