[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How do set focus in tabcontrol

Posted on 2006-12-01
6
Medium Priority
?
345 Views
Last Modified: 2008-02-01
Hi: Can any one please tell me how do i set focus in tab control. I try it but no error and dont work.

Me.Child17.Form.[Service].setfocus

Thanks.
0
Comment
Question by:mustish1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 26

Assisted Solution

by:dannywareham
dannywareham earned 800 total points
ID: 18055408
http://www.mvps.org/access/forms/frm0025.htm

If you are "on" the child subform, then it is simply:

Me.[service].setfocus

If you are on the mainform, you have teh syntax correct
0
 

Author Comment

by:mustish1
ID: 18055429
If I am in the main form

    If IsNull(Me.Child17.Form.[Service]) = True Or Me.Child17.Form.[Service] = "" Then
       MsgBox "Service Required"
       Me.Child17.Form.[Service].SetFocus
       Exit Sub
    End If
0
 

Author Comment

by:mustish1
ID: 18055434
Sorry
If Me.TabCtl12.Pages(Me.TabCtl12.Value).Name = "Add" Then
    If IsNull(Me.Child17.Form.[Service]) = True Or Me.Child17.Form.[Service] = "" Then
       MsgBox "Service Required"
       Me.Child17.Form.[Service].SetFocus
       Exit Sub
    End If
end if
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 26

Assisted Solution

by:dannywareham
dannywareham earned 800 total points
ID: 18055467
?? That looks fine to me...  

Try this:

STOP
If Me.TabCtl12.Pages(Me.TabCtl12.Value).Name = "Add" Then
    If IsNull(Me.Child17.Form.[Service]) Or Me.Child17.Form.[Service] = "" Then
    Me.Child17.Form.[Service].SetFocus      
    MsgBox "Service Required"
    End If
End if


When you click your button, you will be sent to the code screen.
Use F8 to step through the code.

It makes it easier to spot errors.

Hovering your mouse over the variables or controls (like [Service]) will show you what value they're holding.
0
 
LVL 34

Assisted Solution

by:jefftwilley
jefftwilley earned 400 total points
ID: 18056006
Hey M,
Here's a roundabout way

Me.Admin.SetFocus   '<-------------Admin is the NAME of the tab
Me.frm_Export.SetFocus   '<--------this is my subform
DoCmd.GoToControl "ExpList"   '<----this is my control

J
0
 
LVL 44

Accepted Solution

by:
Leigh Purvis earned 800 total points
ID: 18059378
Jeff pretty much has it - though I'd do it differently (just because I'm not a huge fan of GoToControl... or GotoRecord for that matter).

It's an known issue that you can't necessarily set focus to a control in a subform in one fell swoop.
You can be more assured of it working by first setting focus to the subform control and then setting focus to the subform's form control.

With Me.Child17
    .SetFocus                               'Set's focus to a control - which just happens to be a subform control.
    .Form.[Service].SetFocus         'Sets focus to the desired control
End With

Very much the same as Jeff's - just with some reassurance that this can happen and working around it is OK. :-)
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question