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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User Tab or Click on button 1

Status
Not open for further replies.

kamfl610

Programmer
Apr 15, 2003
90
US
Hi,

Need help on something. I have a form that has tab controls. Each tab has fields. When a user tabs from field to field, on the last field on the tab, I use the exit function for to set focus on the first field on the next tab. Works great but now I have a problem if the user clicks on the save button on the last field of the tab, it goes to the set focus and doesn't do my save procedure. How do I recognize when some tabs to the next field vs. when they click on a button. The exit of the field occurs obviously before the save procedure. Anyway, help would be nice. Thanks!
 
How are ya kamfl610 . . . . .

This is very vague . . . . [blue]be more specific![/blue]

Calvin.gif
See Ya! . . . . . .
 
Okay. Here I'll try to diagram it. Below are the tabs. On each tab are fields. Now on the last field of the tab (Info), I do on the exit of the field to go to the first field of the next tab (Misc). So what I want to know is how do I determine if a user tabs from field to field rather than exiting to click a button.

-----\-----\-------\______________________
Info | Misc| Vendor |
__________
Name: |_________|

_______
| Save |
|_____|

Hope this helps!
 
You are correct the setfocus in your Exit event is fired and the Save click never occurs. Couple of things here...first why do you even need the Save Button? (The record automatically saves when you move to a different record) And if you actually need the save button for cosmetic purpose, disable it until you are finished filling in all the controls on your form. Or if you wish to automatically save the record when switching tabs then undirty the form.
 
kamfl610 . . . . .

Sorry to get back so late.
[blue]How do I recognize when some tabs to the next field vs. when they click on a button.[/blue]
Easy . . . in the last field you capture keys and execute code when the [blue]Tab or Enter key is detected.[/blue] In the same way you can accomplish reverse tabbing (Shift + Tab).
Note: the [purple]PageIndex[/purple] of a tab control starts at zero. Here we go ([blue]you![/blue] substitute proper names/values in [purple]purple[/purple]):
[ol][li]Remove the [blue]Exit[/blue] events your using.[/li]
[li]Make sure your [blue]tab order is proper[/blue] for each page.[/li]
[li]In form design view set the [blue]Key Preview[/blue] property to [blue]Yes[/blue] (on the events tab).[/li]
[li]In the [BLUE]KeyDown[/blue] event of the proper textbox, use the following for [purple]Forward Tabbing[/purple]:[/blue]
Code:
[blue]   If Shift = 0 And (KeyCode = 9 Or KeyCode = 13) Then
      Me![purple][b]TabControlName[/b][/purple] = [purple][b]PageIndex[/b][/purple]
   End If[/blue]
[/li]
[li] . . . and for [purple]Reverse Tabbing:[/purple]
Code:
[blue]   If Shift = 1 And KeyCode = 9 Then
      Me![purple][b]TabControlName[/b][/purple] = [purple][b]PageIndex[/b][/purple]
      Me!LastTextboxOnPreviousPageName.SetFocus
   End If[/blue]
[/li][/ol]


Calvin.gif
See Ya! . . . . . .
 
thanks aceman1! You are the man! Works great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top