?
Solved

Subforms - TabIndex not working

Posted on 2003-03-31
9
Medium Priority
?
541 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

719 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