473,554 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

tabbing out of a subform without knowing about the parent

There have been threads in this newsgroup explaining how to
tab out of a subform to the parent form -- without having to
use ctrl-tab (of which users might be unaware -- and at any
rate, they shouldn't have to know that part of a form is
a "subform").

I use a common subform among two main forms, so those solutions
won't work -- because the "next control" depends on who the
parent is. And even if I write fancy code to detect which
parent I have, the subform code will break if I change the
parent's next control.

Here's my brilliant idea, which doesn't work: on the
last control of the subform, check KeyDown and change
TAB to CTRL+TAB, in hopes that Access will recognize it.

Private Sub <LASTCONTROL>_K eyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyTab And Shift <> 1 Then
Shift = 2 ' change ordinary tab (or ctrl-tab) to ctrl-tab
to get out of subform
End If
End Sub

Alas, this does nothing; TAB cycles within the subform.
Maybe KeyDown simply can't pass CTRL+TAB to Access. But, if
if anybody sees a flaw in my code, please post it and we'll
have a wonderful way to TAB our way out of subforms!

Note: you'd have to do a similar check for SHIFT+TAB out of
the *first* control of the subform.

Nov 13 '05 #1
4 8052
On 8 Apr 2005 14:03:40 -0700, "Michael Fay" <fa*@acm.org> wrote:

Interesting idea.
Try using SendKeys instead.

-Tom.

There have been threads in this newsgroup explaining how to
tab out of a subform to the parent form -- without having to
use ctrl-tab (of which users might be unaware -- and at any
rate, they shouldn't have to know that part of a form is
a "subform").

I use a common subform among two main forms, so those solutions
won't work -- because the "next control" depends on who the
parent is. And even if I write fancy code to detect which
parent I have, the subform code will break if I change the
parent's next control.

Here's my brilliant idea, which doesn't work: on the
last control of the subform, check KeyDown and change
TAB to CTRL+TAB, in hopes that Access will recognize it.

Private Sub <LASTCONTROL>_K eyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyTab And Shift <> 1 Then
Shift = 2 ' change ordinary tab (or ctrl-tab) to ctrl-tab
to get out of subform
End If
End Sub

Alas, this does nothing; TAB cycles within the subform.
Maybe KeyDown simply can't pass CTRL+TAB to Access. But, if
if anybody sees a flaw in my code, please post it and we'll
have a wonderful way to TAB our way out of subforms!

Note: you'd have to do a similar check for SHIFT+TAB out of
the *first* control of the subform.


Nov 13 '05 #2
Tom -- SendKeys works! (Mostly.) Now we're close. I fixed the Shift
mask checking and put in SendKeys calls for both the first and last
controls:

Private Sub <LASTCONTROL>_K eyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyTab And ((Shift And acShiftMask) = 0) Then
SendKeys "^{TAB}" ' ctrl-tab moves out to the parent form!
End If
End Sub
Private Sub <FIRSTCONTROL>_ KeyDown(KeyCode As Integer, Shift As
Integer)
If (KeyCode = vbKeyTab) And ((Shift And acShiftMask) > 0) Then
SendKeys "^+{TAB}" ' ctrl-shift-tab moves out backwards to
the parent form!
End If
End Sub

A problem remains: if you TAB your way out to the parent, then
immediately SHIFT-TAB back in, focus passes to the *first* control of
the subform, not the last one. I tried to fool Access with a .SetFocus
call before the SendKeys, but to no avail. Can anyone fix this? The
analogous problem occurs with SHIFT-TAB from the first control,
followed by TAB back in (to the last control).

Folks, if we can get this working perfectly it would make subforms
quite desirable in a number of circumstances:
- common portions of several main forms
- a subform can be attached to a different table from the main form --
in effect you are attaching to two tables, which is impossible
otherwise (without a bunch of awkward code, e.g. copying to a "hidden"
form).

Nov 13 '05 #3
Michael Fay wrote:
Tom -- SendKeys works! (Mostly.) Now we're close. I fixed the Shift
mask checking and put in SendKeys calls for both the first and last
controls:

Private Sub <LASTCONTROL>_K eyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyTab And ((Shift And acShiftMask) = 0) Then
SendKeys "^{TAB}" ' ctrl-tab moves out to the parent form!
End If
End Sub
Private Sub <FIRSTCONTROL>_ KeyDown(KeyCode As Integer, Shift As
Integer)
If (KeyCode = vbKeyTab) And ((Shift And acShiftMask) > 0) Then
SendKeys "^+{TAB}" ' ctrl-shift-tab moves out backwards to
the parent form!
End If
End Sub

A problem remains: if you TAB your way out to the parent, then
immediately SHIFT-TAB back in, focus passes to the *first* control of
the subform, not the last one. I tried to fool Access with a .SetFocus
call before the SendKeys, but to no avail. Can anyone fix this? The
analogous problem occurs with SHIFT-TAB from the first control,
followed by TAB back in (to the last control).

Folks, if we can get this working perfectly it would make subforms
quite desirable in a number of circumstances:
- common portions of several main forms
- a subform can be attached to a different table from the main form --
in effect you are attaching to two tables, which is impossible
otherwise (without a bunch of awkward code, e.g. copying to a "hidden"
form).

There might be an easy safer way to do this. Create a small text box
control on the subform, name it "txtSentry" or some such and make it
last in the tab order. Make it without a border and forecolor/backcolor
to match the Section's values.

Then add code to set focus to the parent for and then some control on
the parent form (I used txtName in this example):

Private Sub txtSentry_GotFo cus()

Me.Parent.Form. SetFocus
Me.Parent.Form! txtName.SetFocu s

End Sub

--
'---------------
'John Mishefske
'---------------
Nov 13 '05 #4
But this has the drawback of putting code in the subform that knows the
name of the next control in the parent form; I was trying to avoid that
kind of dependency.

Also, it looks like you couldn't shift-tab backwards across txtSentry.

This is tricky, isn't it?
- Mike Fay

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2315
by: Rob Tiemens | last post by:
hello, I need to select the first and the second column of a table. But I don't know the names of the columns. Is there any way I can select only the first column from a table without knowing the columnname ? Regards
24
3220
by: gswork | last post by:
Let's write a c program, without knowing what it does... Some of you may recall Jim Roger's excellent series of posts (on comp.programming) exploring the implementation of common software activities in different languages by requesting small working programs as source. Well, having thought & read about the benefits of teamwork, oss,...
2
1786
by: AdamM | last post by:
Currently, my code reads from a database without knowing the order of the columns like this: string name = (string)datarow; However, is there a way to write or do an INSERT back to a database without getting caught up in the order of the columns? Right now I do something like this, which is delicate and breaks if the order of the columns...
4
8704
by: Charles Law | last post by:
Is there a way to dynamically remove an event handler from an event without knowing the name of the handler? For example, how can ClassB remove the handler without knowing the name, or how many handlers there are? <code> Public Class ClassA Private m_ClassB As New ClassB
3
1281
by: farseer | last post by:
If i have an array of a certain type, is there away of initializing with without knowing it's type? for example (forgive me if some of this is syntactically incorrect) if i have a procedure like this private sub addElements( target() as Object , elemsToAdd () as object ) begin if ( arr is Nothing ) then {initialize with correct type}
3
1762
by: Familjen Karlsson | last post by:
Here is an example from the help on the keword OleDbConnection, in VB.Net, they don't give the path to the database just the word localhost. How can it connect to the database without knowing where it is. What does the keyword localhost do. Thank's Fia Public Sub InsertRow(myConnectionString As String)
5
2460
by: Luqman | last post by:
How can Administrator change the Password of existing User, without knowing his Old Password in Administer Security Tool ? One user has forgot his password, and Administer wants to refresh it. Best Regards, Luqman
11
1083
by: John | last post by:
Hi I have a data row variable which could be for any of a number of tables in my apps. How can I type cast the variable to correct type at runtime? I know I can get the type description using MyRow.ToString but don't know how to use this to typecast MyRow variable. I need this to write a generic SUB that can deal with rows of any table...
2
2480
by: Parmenides | last post by:
I get the "this record has been changed by another user since you started editing it" message when I first make an edit in a subform then click on anything in the parent area. It won't give me the option to save, just "copy to clipboard" or "drop." Both the parent and the subform use the same table in their RecordSource. The only difference...
0
7603
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...
0
8047
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...
1
7568
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6151
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...
1
5439
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5159
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...
0
3553
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1139
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
845
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.