Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Snap-to" Function; or Default Curser target. 1

Status
Not open for further replies.

MSWhat

IS-IT--Management
Jul 19, 2007
62
US
Hi, all.

I'm having an annoying issue with my DB that I can't seem to figure out how to fix. I have a form with multiple tabs. In one of the tabs towards the middle there is some information (most of which is actually carried over in locked text box from information entered on previous tabs) and to the right of the information is a sub form. Whenever you click on this tab, the cursor automatically goes straight to the first field within the subform. The problem with this is that in going straight to the subform, the screen scrolls to the right a bit, and you cannot see that there is anything/what is to the left of the subform.

I'm not sure if that was clear enough, but basically I'm looking for a way to either set a specific field as the field to witch the cursor automatically snaps, OR set it so the cursor defaults to going to the form instead of the subform.

Thanks for your help in advance.

*Note: I tried going to Tools>Options>Keyboard tab>and checking "Cursor stops at first/last tab" but that seemed to be of no use.
 
Code:
Private Sub YourTabbedPageName_Click()
 ControlToGetFocusName.SetFocus
End Sub

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Thanks, thanks, thanks again, Missinglinq.

However, being new to this all, where do I put that in? Do I set that as an On Enter event? And when, in the code, you say "YourTabbedPageName," do I put the lable of the tab? And in the parenthesis of "Click()", do I put anything?

Sorry for my ignorance, but thanks for your help.
 
I forgot to say:

I tried entering it as an On Enter event for the field to which I want the cursor to snap and it didn't work. Though maybe that's because for the "YourTabbedPageName" I wrongfully entered "BankAccountInfoTab"--the name of the tab in which that field is located.

Thanks again.
 
missinglinq suggested you the Click event procedure of the relevant Page object of your TabControl ...
 
Thanks for weighing in, PH. So I built that as an event procedure on the relevant page. But there is something incorrect wiht the code. I know that what must be missing is the name of the field to which I want the cursor to snap ("Investment Fund Name Lable"). But I just don't know where it goes.

Ahhh sorry. I just don't know VBA code at all.
 
Note: I built it as an event procedure by opening my form in design view, right clicking the specific tab, selecting "build event" and then pasted that code (entering in the name of the tab). Did I do that correctly?
 
For me, the correct way is to click the ellipsis (...) in the OnClick row of the property sheet.

You wanted this ?
Me![Investment Fund Name Lable].SetFocus

BTW, a Label can't have the focus.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks so much, PH. So I tried what you gave to me. I made the OnClick event of the tab this:

Private Sub Bank_Account_Info_Tab_Click()
Me![Investment Fund Name Lable].SetFocus
End Sub

However, it's not working. It's still snapping to the first cell of the subform, rather than this text box. Hrmmmm....

Thoughts?
 
Me![Investment Fund Name Lable].SetFocus would suggest, by its name, that you're trying to set the focus on a label! Label cannot receive focus! You have to set it to a control that can receive focus, like a textbox.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
No. Sorry for the confusion. It's not a label, it's just what I called the textbox. That's definitely the name of the textbox.

Any ideas? Thanks again.
 
actually carried over in locked text box
So you want to set the focus to a locked textbox ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yup. I'd love to set the focus to a locked textbox. If it was impossible to do, I'd be willing to unlock it.

Thanks, thanks, thanks, PH.
 
I tried unlocking it but that was to no avail. I've plugged in the code recommended and that's not fixing it either, but I can't seem to figure out why it's not working.
 
I also tried making the "On Click" event procedure of the the tab a "GoToControl" Macro. I think I wrote the macro properly, but it still doesn't work.

hrmmmm.
 
After doing a bunch of research, I've concluded that Access will automatically set focus to the subform of a tab, and is not able to automatically set focus to a control within the tab of the main form, not the subform. Thanks PH and MissingLinq for your attempted help on this. I apprecaite it a lot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top