Solved

How do set focus in tabcontrol

Posted on 2006-12-01
6
336 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
6 Comments
 
LVL 26

Assisted Solution

by:dannywareham
dannywareham earned 200 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 26

Assisted Solution

by:dannywareham
dannywareham earned 200 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 100 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 200 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

910 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now