Full Version: Tabbing through Tab Controls - possible?
UtterAccess Forums > Microsoft® Access > Access Forms
Ruth_67
I have a form that has a Tab Control with multiple pages. Each page has 1 or more fields on it (not subforms or anything like that). I would like for the user to be able to tab through all the fields on the form, including those on the tab control, but I can't seem to get it to do that.
Is this possible?
balaji
I think you will find your answer in this thread.
Ruth_67
Not really.
Here's the dilemma. I have a macro that runs whenever you move from record to record called GoToNextRecord (it's on the form's OnCurrent event). Among many other things, it sets focus on the first tab of my Tab Control (so that if the user left off on a different tab on the previous record, it puts the first tab in "front") and then moves to another field on the form. Note: the macro specifically refers to the PAGE name (IssueDescription_Page), not the field on it.
Ok, so now we put a macro (that triggers on Lost Focus) called GoToActionPlan on the field (Issue Description) on that page, that puts focus on the field on the next tab.
Hypothetically, I would expect that to work. Unfortunately, when GoToNextRecord fires, it puts focus not on the page (IssueDescription_Page) but on the field on that page (IssueDescription). Because focus is now on the IssueDescription field, the GoToActionPlan macro fires which puts focus on the second tab and the GoToNextRecord event fails.
To try and work around this, I put a test text field on the IssueDescription_Page and set the GoToNextRecord macro to point to that field and then move to the next field I want to have focus, but that didn't help. I also tried putting the GoToActionPlan macro on the Exit event for the IssueDescription field, but that didn't work either.
So, based on my current configuration, it appears that the GoToNextRecord does not differentiate a tab page from the fields on it since it works the same whether you refer to the page or to a field on the page.
This leaves me with the 2 following questions:
How to make a macro differentiate between a tab page and a field on it?
OR
Is there some other way to accomplish my task.

I have attached a stripped down copy of the database to make it easier. Note: The MoveScreenUp field is the yellow box at the top of the Issues form. It is very small, has no fill and no border but I made it bigger to avoid confusion.
balaji
You should not need a macro to put your focus on the first control on the first page of your form. If you set the tab index property of your controls properly, when you move to the next record, focus will automatically be on the first control that has the lowest tab index.
lso, I don't understand why GoToActionPlan fires as soon as this control gets the focus if it is on Lostfocus() event. The LostFocus() event should not fire until this control loses focus.
Ruth_67
I have the tabs in the Tab Control properly Page Indexed but unless I include the command to go to the IssueDescription_Page, the tab displayed is whatever tab was last used when you go to the next record. For example, if you make an edit in Record of Follow-up and then roll to the next record, Record of Follow-up stays as the displayed tab in the new record. You can see this behavior if you remove that line of code from the macro in the database I attached to my last post.
Is for why the GoToActionPlan fires when the field gets focus, your guess is as good as mine. As the code is currently written, the field never receives focus...just the page. But, assuming the page=field in the macro, the field will lose focus because the next command moves focus to a different field. However, when I tested the macro such that the last command was to put focus on the page=field, the GoToActionPlan still fired once the GoToNextRecord macro finished.
So all that amounts to IT'S NOT WORKING LIKE IT SHOULD!!!! ARRRRGGGHHHH.
balaji
Maybe you should forget about setting focus in your macros and use the method suggested in the thread I referred you to where the last control on each page has code to move the focus to the first control on the next page in the lostfocus() event. I do not use macros and am not familiar with all the nuances of using them. I only know that they are very limiting compared to VBA.
Ruth_67
This is not an option because then the users will never know where they will end up in the next ticket. The macro that runs when you move from record to record is highly critical as it determines what fields are displayed and the value of critical reporting fields (I took much of that functionality out in the example database I supplied).
balaji
I am not saying that you should completely relieve yourself of the responsibility for setting the focus correctly. I am just saying do that part in VBA code as presented in the other thread and do the rest of your processing (if it is being done correctly and you are more comfortable with it) in the macro. So, in the oncurrent() event of the form, you would have code to set the focus to the appropriate control so that whenever the user moves to a different record, focus falls on the control you want it to fall on. Then, in the lostfocus() event of the last control of each page, you would have code to set the focus to the first control of the next page.
Ruth_67
OOH...Would VBA code recognize the difference between a page and a field on a page (unlike the macro does)?
'd have to first make sure that all the code I am running via the macro can be run via VBA. Ok, clearly I have some fiddling to do here.
Related question: What runs faster...macros or VBA code?
Oask because the macro in question often produces a delay of about 5 seconds, give or take. If VBA code runs faster...that would be nice. (hows that for greed...whining about 5 crummy seconds).
balaji
In VBA, you can set the focus to any individual control using syntax as below:
e.mycontrol.setfocus
That is all it takes. I have never tried to set focus to a tab page, but since the tab pages do have names, I would think it would be possible to set focus to a tab page if necessary.
I am only going to guess here, but I would say VBA would probably blow the doors off a macro easily.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.