Navigating a Tabbed Form

Tophan

Registered User.
Local time
Today, 14:02
Joined
Mar 27, 2011
Messages
389
I have a form which consists of four (4) tabbed sheets. The first sheet is the main form and the other three sheets are the linked subforms.

Pressing the tab key on the keyboard navigates from field to field in each individual form; however, I would like that when I get to the last field of each form, pressing tab moves to the next sheet or the first field of the next subform.

The problem I am getting is that when I get to the last field of the main form and/or subforms, hitting the tab button creates a new record in the specific form, which I do not want. I want to just tab to the next subform.

Hope I explained the problem clearly and looking forward to any help you can offer.

Thanks
 
You may consider having your own controls (buttons or other) that move to your desired location when clicked. Seems you have determine how Access is moving based on Tab key, so if that doesn't work for you, then customization seems appropriate.
 
I'm not sure if that is exactly what I need. The form tabs are clearly labelled and navigating to an individual subform by clicking the tab is working fine. The problem I am experiencing is that when I am just keying in the information and tabbing from field to field, when I get to the last field of the main form/subform, tabbing creates the next record as opposed to navigating to the first field of the next form.

Also, when I get the the last field of the last form, I would like that when I hit the tab button that the control automatically goes to the "Print Form" button and does not create a new record.

Is there any way of preventing a new record from automatically being created after entry in the last field of a form?
 
Possible solutions could be a long the lines of using VBA to manually set focus to whatever you want on the 'Lost Focus' event of the last object. Thus when you tab off the object, hopefully that would class as it losing the focus and run your code to jump the focus to a new location.
 
The main form name is "Contracts". Last field on that form is "Other" which is a memo field for entering additional information.

The first sub-form name is "Personnel" and the first field on that form is named "DirectorInCharge"

I went to the On Lost Focus event for field name "Other" in the main form and typed the following:

Private Sub Other_LostFocus()
Me!Personnel.SetFocus
Me!Personnel.Form!DirectorInCharge.SetFocus
End Sub

I keep getting the following error message:

Run-time error '2465':
Microsoft Access can't find the field "Personnel" referred to in your expression

Can someone tell me where I've gone wrong? Personnel is the Sub-form name not a field name.
 
Getting the same error message. It is trying to look for a field named "Personnel" instead of a form named "Personnel"
 
Getting the same error message. It is trying to look for a field named "Personnel" instead of a form named "Personnel"

Very strange. Is the subform object (like the frame that is holding the subform in the parent form) also named Personnel? (I think it needs to be if not.)
 
Ok...Frame Name = Personnel
Sub Form Name = Personnel
Main Form = Contracts

Private Sub Other_LostFocus()
Forms!Contracts!Personnel.Form.DirectorInCharge.SetFocus
End Sub

Getting a different error message now

Run-time error 438. Object doesn't support this property or method

I know we are heading in the right direction here but there is something I am doing wrong and I can't quite figure it out. I'm checking all the form names and spelling, etc. and also inter-changing the "period" with the "exclamation" to see if it is something like that that is causing the error
Now I'
 
Quick question...if an object name is more than one word how do you write it in the code?

For instance, I have a second sub-form named "Client Info" which is linked to the master form "Contracts". If I were trying to do the same type of code for "Client Info" would I type it at Client_Info?
 
google documentation for Access set focus
When subforms are involved it is a two-step dance.

For how to refer to objects use the Expression Builder - eg. create a text box, and in its Control SOurce property click on the ellipses and navigate to the control of interest. Click Paste and now you have the reference in the ControlSource property.

update: for fun, you may also want to look into each subform's Property Sheet>Other>Cycle
 
Last edited:
I have tried every which way and I can't get the code to work :(
 
Walked around at the internet and found something at Microsoft:

An example:

Private Sub cmdSearch_LostFocus()
Me![frmSub].Form!txtcar.SetFocus
End Sub

With this code after tabbing around at the form, the next tab wil direct you to the subform of the form and also directly to the first field of the subform

I hope this will help you a step forward:o
 
Thank you both...I will try again today and let you know if I get through.
 

Users who are viewing this thread

Back
Top Bottom