?
Solved

Subforms - TabIndex not working

Posted on 2003-03-31
9
Medium Priority
?
559 Views
Last Modified: 2012-05-04
I have a form called Customers which has 15 fields.  I added a subform called Sales(7 fields) underneath using the linking field ClientID. When I get to the last field in the Customer form (tab stop 15) it then tabs back to the first field of the customer form not the 1st field of the Sales subform. I tried to set the Tab Index of the first field of the Sales Subform to 16 but I get an error message saying "the value you used for the TabIndex property isnt valid. The correct values are from 0 to 7".  What I would like is to be able to continue entering data in the Sales subform after I have entered the data in the last field of the Customer Table and then go to the next record.  Also once I have inputted the ClientID in the customer form I would like the ClientID in the Sales form to automatically appear.

Can anyone help. Thanks in advance.
0
Comment
Question by:suni_p
  • 5
  • 3
9 Comments
 
LVL 2

Expert Comment

by:Matt-the-HAT
ID: 8237547
Set the tab stop for the subform itself, the subforms own tab stop list should then take over.

Access 2002 (XP) and 2000 (I think) has a wizard for setting the tab order.
0
 
LVL 8

Expert Comment

by:HaydnH
ID: 8237618
Hi Suni,

As Matt says, the tab index of the main form will show the name of the sub form, NOT the name of the controls with in that form.

If you still have problems, you can change the focus to the control of your choice on the subform by doing the following:

 - Right click the last control on the main form
 - Select properties -> events
 - click in the After Update box and click the "..." next to it
 - double click code builder


This will appear in the code builder window:

  Private Sub LastControlName_AfterUpdate()

  End Sub


Add the following in the middle to make:


  Private Sub LastControlName_AfterUpdate()
    DoCmd.GoToControl "SubFormName"
    DoCmd.GoToControl "SubFormControlName"
  End Sub


Hope that helps =)

HaydnH.
0
 

Author Comment

by:suni_p
ID: 8237663
Hi Haydn,

Thanks for getting back to me so quickly.  Your code does take me to the control I want but after I input something in this field I can't move to the next field. It sort of stays frozen on that control.

Appreciate your help.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 8

Expert Comment

by:HaydnH
ID: 8237798
Hi Suni,

Open the Sub form in form view on its own (i.e: not via the main form) and check that you can tab through the fields from the control you're tabbing to via the above source.

If you can tab through there then you should be able to tab through in the main form as once your sub form gains focus it effectively running as it is on its own. So, if you can tab through there then go back to the design of the main form. Check all code and the properties relating to the sub form** - perhpaps it's locked or has tab = no set or similar.

**Note: there are 2 properties u can access for sub forms, 1 by highlighting the border of the sub form, the other by selecting the "check box" in the top left of the sub form.


However, if you can't tab through when only the sub form is open then you must have some code or a property intercepting the tab key on that form. Check any code you have regarding keydown/up and the tab key** in that sub forms design view.

Useful tip, if you want to stop a key from doing what it usualy does add the "keycode = 0" line to the end of the KeyUp/Down event Sub.

Hope that helps,

HaydnH.
0
 

Author Comment

by:suni_p
ID: 8237912
Thanks the tab is no longer stuck and is working but once it reaches the last field of the Sales Subform it returns to the beginning of the Sales subform not the Customer Form.  The two forms dont appear to working together.  
0
 
LVL 8

Expert Comment

by:HaydnH
ID: 8237953
Open the main form and enter some data in the sub form, then tab to the end of the form... make sure that after you get to the end of the sub form the data doesn't dissapear... if it does that means a new entry has been added in the subforms table relating to the main forms ID.

What type of sub form are you trying to use?

 - A single sub form? (like a balance sheet)
 - A continuos form (N records listed below each other)

HaydnH.
0
 
LVL 8

Accepted Solution

by:
HaydnH earned 120 total points
ID: 8237968
oh, I read that wrong... sorry...

The way it's working is correct... to get from the sub from to the next control on the main form use ctrl-tab not just tab!

Alternatively u can set up another key to move on, personally I like the enter key if it's a data entry form - nice and quick to press and it's usualy so similar to tab.

To do this repeat the following for each control on the sub form:

 - right click the control
 - select properties -> events
 - click onKyeDown box and the "..." next to it


enter the following in the code window:

  Private Sub CurrentSubFormControlName_KeyDown(KeyCode As Integer, Shift As Integer)
    If (KeyCode = 13) Then
   
      DoCmd.GoToControl "MainFormControlName"
      KeyCode = 0

    End If
  End Sub

NOTE: 13 is the ascii value for carriage return.

If you want to move to another sub form on the main form you'll need to add another GoToControl line exactly the same above the existing 1 but with the sub form name.

HaydhH.
0
 

Author Comment

by:suni_p
ID: 8238337
Hi. Thanks for your all your help.  Very much appreciated.
I couldnt get the last keydown command to work but thats OK.

0
 
LVL 8

Expert Comment

by:HaydnH
ID: 8239126
np, if you decide you want to get that last KeyDown sub working post in here... I'll leave my mail updates for this thread open for a while.

HaydnH
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question