tabcontrol - MS Access Tab Control: Wrong focus -


i have tab control different pages. when starting form tab control tabs lost , inner page gets screen focus. tab control used navigation user lost way.

is there way let tabs visible on screen without resizing screen smaller?

desired result:

+--------------------+ | tab1 | tab2 | tab3 | +--------------------+ | name: ______       | 

actual screen:

                        ^ +--------------------+ |_| | name: ______       | | | 

reducing size of tab control works (as discovered yourself), there alternative workaround:

  1. add command button , align top left corner of tab control
  2. set tab stop property no (in 'other' tab of command button property sheet)
  3. send put command button behind tab control
  4. in form's onopen or onload event, call .setfocus method on command button
  5. use sendkeys (i know, know...) tab tab control

sample code:

private sub form_open(cancel integer)     me.hiddencommandbutton.setfocus     sendkeys "{tab}" end sub 

explanation of above steps:

  1. this allows dictate access should line form on screen.
  2. setting tab stop no command button prevents users accidentally tabbing , causing confusion.
  3. sending button hides user , prevents interfering mouse clicking.
  4. setting focus command button @ form start necessary since turned off tab stop property in step 2.
  5. using sendkeys (always last resort, , reason) simulate tab press provides "keyboard focus" tab control (as long tab control first control in tab order whatever section of form control part of).

miscellaneous notes: @ asker's request including couple of comments part of answer itself:

@mwolfe: 1 final note on sendkeys...it blows under uac in vista/win7. if can live without keyboard focus, i'd leave sendkeys out entirely. if need you'll either want add error handling ignore error (if don't mind of users losing keyboard focus functionality) or bypass sendkeys , use winapi directly. karl peterson offers turnkey solution here: vb.mvps.org/samples/sendinput have never used can't comment on reliability, karl microsoft mvp he's credibility.

@roman glass: mwolfe02 trust in method work, focus crucial me , users working under windows 7. drop issue moment find out user reactions. nevertheless think solution deserves solved. in end have talk winapi. maybe can edit answer include comment directly. thanks!

for may find answer in future, please take note step 5 above necessary if need tab control receive keyboard focus (a critical requirement original asker). if can live without it, suggest do.

update: david fenton points out in comments, can use ctl + tab/ctl + shift + tab move , forth between tabs. consistent tabbed interfaces (eg, browsers) , eliminates need use sendkeys.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -