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

Form with Header and Detail, need to control tab order

Status
Not open for further replies.

cmmrfrds

Programmer
Feb 13, 2000
4,690
US
I have a Form where there is a header and variable number of detail lines. I build the number of detail lines from criteria in one of my tables. So, when the Form opens there will be the number of detail lines that match my criteria. The tab order is column 1 to 4 and then the next line etc.. until the last column on the last line. On the last line the tab goes from the last column to the first column on the last line. I need the tab to go to an Update button on my form header. The way it works now is I need to press the update bar on the left side of the Form to update the last line. I need to make sure this last line gets updated without pressing the update bar. I can live with making the update happen without the tab, but preferrably tab to the update button.<br>
<br>
Any ideas?<br>
<br>
Thank you in advance.
 
I narrowed the problem down to the last record in a recordset where additions are not allowed. It seems that if one is on the last record of a recordset the tab key will not advance off the record. In my testing, I have failed to update the record and I am sure my users will run into the same problem. Any suggestions will be appreciated.
 
Access doesn't have any built-in way of exiting a section of a report that I know of. One way of getting out of a section is to make control the last tab item in that section, and use the .SetFocus method within the control's OnGotFocus event. I'm not sure how this will work out though if you have multiple detail records.
 
above should read &quot;... is to make another control that is the last tab item in that section...&quot; BTW when I've used this method use a label set to Visible = No/False.
 
Here is the code for the last thing I tried.<br>
I put the code in the OnKeyPress event, but it always generates Ascii 9 regardless of which key I press. If I use Ascii 9, when I tab into the last field it takes off before I can enter the number. Any thoughts?<br>
Here is the event.<br>
<br>
Private Sub column2_KeyPress(KeyAscii As Integer)<br>
'<br>
Dim bookCompare As Variant<br>
<br>
bookCompare = (StrComp(FmaxLines, Me.Bookmark))<br>
Debug.Print &quot;Col 2 bookCompare = &quot;; bookCompare<br>
'''--- if (0 True, -1 less then, 1 greater than) compare first to second string<br>
If bookCompare &lt;&gt; 0 Then '' only need to check on last line<br>
Exit Sub<br>
End If<br>
<br>
Debug.Print &quot;column3 locked = &quot;; column3.Locked<br>
<br>
If column3.Locked = False Then '' only need to check on last active column<br>
Exit Sub<br>
End If<br>
Debug.Print &quot;Ascii Key = &quot;; KeyAscii<br>
If (KeyAscii = 10) Then '''--------- linefeed<br>
Me.UpdateButton.SetFocus<br>
Exit Sub<br>
End If<br>
If (KeyAscii = 11) Then '''--------- vertical tab<br>
Me.UpdateButton.SetFocus<br>
Exit Sub<br>
End If<br>
If (KeyAscii = 13) Then '''--------- carriage return<br>
Me.UpdateButton.SetFocus<br>
End If<br>
<br>
End Sub<br>
<br>
I have 4 columns on the last line so I check each column. Columns 2-4 can be locked so they will have no input. The Form can have a max of 4 columns but open ended on lines. This test had 4 lines and 2 columns active. I noticed an ascii 53 and I am not sure how I generated it or what it stands for. I tried first horizontal tab, carriage return, then vertical tab. On all these an Ascii 9 was generated and since I don't set focus on Ascii 9 the focus stays on the last line.<br>
<br>
Thank you,<br>
Jerry<br>

 
I got it to work. Thanks for the help.<br>
Here is the code I used placed in the OnExit Event.<br>
'<br>
Dim bookCompare As Variant<br>
<br>
bookCompare = (StrComp(FmaxLines, Me.Bookmark))<br>
''''--Debug.Print &quot;bookCompare = &quot;; bookCompare<br>
'''--- if (0 True, -1 less then, 1 greater than) compare first to second string<br>
If bookCompare &lt;&gt; 0 Then '' only need to check on last line<br>
Exit Sub<br>
End If<br>
<br>
Debug.Print &quot;column4 locked = &quot;; column4.Locked<br>
<br>
If column4.Locked = False Then '' only need to check on last active column<br>
Exit Sub<br>
End If<br>
<br>
Dim ctl As Control, RST As Recordset<br>
Set ctl = Me.UpdateButton<br>
Set RST = Me.RecordsetClone<br>
RST.Bookmark = Me.Bookmark<br>
RST.Edit<br>
RST.Update<br>
RST.Close<br>
DoCmd.GoToControl (ctl.Name)<br>
<br>
<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top