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>_KeyDown(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. 4 7921
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>_KeyDown(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.
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>_KeyDown(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).
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>_KeyDown(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_GotFocus()
Me.Parent.Form.SetFocus
Me.Parent.Form!txtName.SetFocus
End Sub
--
'---------------
'John Mishefske
'---------------
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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)...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
| |