Solved

How do set focus in tabcontrol

Posted on 2006-12-01
6
339 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

821 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