473,898 Members | 2,203 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Make a button on a tab control focused so you can hit the Space Bar

99 New Member
I am trying to set the focus on a button that sits on page 1 of my tab control. It looks like I'm successful at setting the focus because I see the highlight on the button, but when I push the space-bar, I get the sub menu for the main form; the button does not press down. I notice that when I click on the tab control, the highlighted button takes on an "added highlight". It looks like a dotted line over the original highlight. If I press the space-bar after this additional highlight appears, the button presses properly. Here is the code I'm using now to set the focus to the button on the tab control...

Me!tabAllTabs.P ages(0).Control s!cmdAddNote.Se tFocus

How do I get that button to the point that I only need to hit the space-bar to press it, without clicking on the tab control?

... and what is this additional state called? I thought that once you set the focus on a button, you needed only press space or enter to engage it.

Thanks,
Adam
Nov 24 '09 #1
21 4838
ChipR
1,287 Recognized Expert Top Contributor
Controls on tabs are referred to the same way as controls on the main form. You should be able to use from main form code:
Expand|Select|Wrap|Line Numbers
  1. cmdAddNote.SetFocus
Nov 24 '09 #2
topher23
234 Recognized Expert New Member
I just did some research on this, and what I learned is kind of interesting.

First off, though, may I say I'd never seen anyone refer to a control on a tab control page through the controls collection of the page. I would never have even thought of it.

It appears that, when referencing the control through the route described, the control doesn't receive the focus until the page receives the focus, due to the way the reference is called. It's sort of like when you have focus on a control in one form, then open another form. When the second form opens, the control that had the focus in the old form is still selected, but it won't actually get the focus unless that form becomes the active form.

So, by referencing it in that method, you've in essence selected it, but are unable to give it the actual "focus" unless the page is given focus. If you set the focus for the control directly through the form, which is active and has focus, then focus is on that control immediately.
Nov 25 '09 #3
AdamOnAccess
99 New Member
ChipR, Topher23,

Thank you both for the response.

ChipR, I originally tried what you suggested and got the same result; the button was selected but still did not respond to the space-bar as a push.

Topher,
Your description of how it works sounds right to me, but I still can't get it to work.

I've tried this...
Expand|Select|Wrap|Line Numbers
  1. Me!cmdAddNotes.SetFocus
and this...
Expand|Select|Wrap|Line Numbers
  1. Me!tabAllTabs.Pages(0).Controls!cmdAddNotes.SetFocus
and this...
Expand|Select|Wrap|Line Numbers
  1. Me.SetFocus 'set focus to form first
  2. Me!cmdAddNotes.SetFocus
and this...
Expand|Select|Wrap|Line Numbers
  1. Me!tabAllTabs.Pages(0).SetFocus 'set focus to tab control page 1 first
  2. Me!cmdAddNotes.SetFocus
... all generate the same result; the button is selected, but it will not respond to a "push" from the space-bar or enter-key until the form is actually clicked.

Here's a little more info: I'm trying to set this in an event procedure generated from the Web Browser Control, Document Complete Event...
Expand|Select|Wrap|Line Numbers
  1. Private Sub wbbWebsite_DocumentComplete(ByVal pDisp As Object, URL As Variant)
  2.     Me!txbPageTitle = Me!wbbWebsite.LocationName
  3.  
  4.     'Me!cmdAddNotes.SetFocus
  5.  
  6.     'Me!tabAllTabs.Pages(0).Controls!cmdAddNotes.SetFocus
  7.  
  8.     Me.SetFocus
  9.     Me!cmdAddNotes.SetFocus
  10. End Sub
The results are always the same. The button is selected, but does not respond to the enter button or space bar until I click on the form. I can't get it to work.
Nov 25 '09 #4
ChipR
1,287 Recognized Expert Top Contributor
Well, I'm stuck. I wanted to try this out with the Web Browser Control, but I can't find it in Access 2007.
Nov 25 '09 #5
mshmyob
904 Recognized Expert Contributor
@ChipR
It's there, you are just not looking hard enough :).

Look under the ActiveX components and then Microsoft Web Browser.

You may also need to make a reference to the Microsoft HTML Controls

cheers,
Nov 25 '09 #6
AdamOnAccess
99 New Member
Ok, apparently this has nothing to do with the tab control. I tried to set focus to a button on the main form and I have the same problem: The button is selected but it does not respond to a push from either the enter key or the space bar. It will only respond after I click on the form.

Thanks for all the help,
Adam
Nov 25 '09 #7
mshmyob
904 Recognized Expert Contributor
@AdamOnAccess
I haven't tried the problem you are having yet but if you do not need to manually press the key why don't you use the sendkey function to simulate pressing the button? Will that be satisfactory for you?

cheers,
Nov 25 '09 #8
mshmyob
904 Recognized Expert Contributor
I just tried the scenario with a main form/ sub form and had same problem. But then I used the sendkeys statement and it worked.

sendkeys "{ENTER}" did the trick for me after setting focus to the button.

cheers,
Nov 25 '09 #9
ChipR
1,287 Recognized Expert Top Contributor
I'm still suspicious of the web browser control, but I don't have a Microsoft HTML Controls reference to enable. The Microsoft HTML Objects reference didn't help. Anyone know if there's something I have to download?
Nov 25 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
5146
by: Jason Kyle Baginski | last post by:
Here's a little test app to demonstrate a problem I'm having. It creates four buttons, each one with the different FlatStyle types available. Three of them behave exactly the same way(and the way I'd anticipate), but the FlatStyle.System one does not. If you click on any of the buttons, use the enter key, or the spacebar, they will bring up a messagebox that says "Activate". Except the FlatStyle.System one, which will bring up _two_...
18
3084
by: jrhoads23 | last post by:
Hello, I am trying to find a way to tell if an .NET windows forms Button (System.Windows.Forms.Button) is "depressed" (pushed down). For my application, I can not use a check box control set to button style, I must use a System.Windows.Forms.Button. I can not find a way to tell when it is momentaraly pressed. I tried calling the API SendMessage with the button handle and BM_GETSTATE to get the state of the button. This will only return...
2
2437
by: jrhoads23 | last post by:
If you look at a standard Button in a .NET Windows Forms app, you will notice its default BackColor is "Control" and it has a 3D raised border which is 2 pixels wide. The outer edge on the left and top is "ControlLightLight" color and the inner edge on the left and top is "ControlLight". The outer edge on the right and bottom is "ControlDarkDark" and the inner edge on the right and bottom is "ControlDark". All of these colors are defined...
2
1014
by: David Cho | last post by:
After the user fills out the webform, my customer would like a default button on the form to have focus, so that all the user has to do is press <enter> as opposed to having to take the cursor and click. The problem is that I have buttons in a user control (its a navigation control) across the top of the page. So the button in the left upper corner always has focus, and that is not the button that the customer wants focused. Is there...
12
7398
by: SJ | last post by:
Hope someone can help me out there I'm struggling with a particular problem... I have a form with many tab pages. On one tab page I've got a button which when clicked with a mouse adds items into a datagrid. When a user presses the enter key on this button I want the mouse click event to be activated but instead the tab page's validating event is called. I understand that this behaviour is by partly by design (Accept button etc) but I...
3
1614
by: Boni | last post by:
Dear all, if I have a Form and some controls on it, how can I get a pointer to the focused control. I what to remember focused control, do some operations and then restore focus
1
1966
by: Gary | last post by:
There are several controls in my form. How to detect currently which control has the forcus and set the forcus to a certain control? Thanks,
0
1296
by: gnewsgroup | last post by:
A aspx page of mine contains a user control in a Panel control. This user control has a textbox, a search button and a cancel button like this: btnSearch btnCancel When btnSearch is clicked, I show the search result right in the user control. If btnCancel is clicked, the user control dissappears. Everything works OK if I simply use mouse-clicks.
3
1600
pentahari
by: pentahari | last post by:
In VB6, I have created the form look like the message box. but one problem has occurred that the one button had already focused but the rectangle focus symbol appeared on the focused button. But the msgbox don't have the rectangle focus symbol on the focused button. For ex: MsgBox "Are you sure?", vbYesNo The above msgbox automatically focus the yes button but no rectangle symbol.
0
9993
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11254
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10854
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9658
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7187
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5876
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4295
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.