Solved

How do set focus in tabcontrol

Posted on 2006-12-01
6
333 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

744 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

11 Experts available now in Live!

Get 1:1 Help Now