Moving from subform to subform

D

Deena

I have a form that consists of a MainForm, and a Subform
that has its own Subform (subform1 and subform1A). I
cannot get the TAB button to move from the last tab stop
of the Subform1 to the first tab stop of its Subform1A.
I have both subforms set to Cycle=Current Record, but
subform1 brings up a new record and sets the focus to the
first tab stop on subform1 when you tab out of the last
tab stop on subform1. Subform1 just cycles on itself.
Any ideas what to check and how to make this work?
 
J

Jim Pavek

Try this on the Key Down Event:
foo = SubformExit_Next(Me, KeyCode, "Put SubForm Name Here")

Put this is your Utilities Module:
Function SubformExit_Next(frm As Form, KeyCode As Integer, strMoveToField As
String, Optional booMoveToFirst As Boolean = True)
' Comments : used to move out of the last record on a subform, called
' from the last fields KeyDown event.
'
' frm - the subform
' KeyCode - the key that was pressed
' strMoveToField - the next parent form field to move to
' booMoveToFirst - should the subform record position be set
to the first record in the subform - default = true
'
' Modified : Squarei Technologies- 03/08/2000
' --------------------------------------------------------
Dim ctl As Control
Dim intRecordCount As Integer

On Error Resume Next
Set ctl = Screen.ActiveControl
If IsComboOpen() = False Then
If ctl.ControlType = acComboBox And (KeyCode = vbKeyDown Or KeyCode =
vbKeyUp) And (InStr(ctl.Tag, "[Ignore_Navigation]") > 0) Then
Exit Function
Else
Select Case KeyCode
Case vbKeyTab, vbKeyReturn, vbKeyDown
If frm.AllowAdditions = True Then
intRecordCount = frm.RecordsetClone.RecordCount + 1
Else
intRecordCount = frm.RecordsetClone.RecordCount
End If
If strMoveToField = "" Then Exit Function
If frm.CurrentRecord = intRecordCount Then
If frm.NewRecord = True And frm.Dirty = True Then Exit Function
If booMoveToFirst = True Then
DoCmd.GoToRecord , , acFirst
End If
frm.Parent(strMoveToField).SetFocus
End If
Case Else
'do nothing
End Select
End If
End If
End Function
 
D

Deena

-----Original Message-----
Try this on the Key Down Event:
foo = SubformExit_Next(Me, KeyCode, "Put SubForm Name Here")

Put this is your Utilities Module:
Function SubformExit_Next(frm As Form, KeyCode As Integer, strMoveToField As
String, Optional booMoveToFirst As Boolean = True)
' Comments : used to move out of the last record on a subform, called
' from the last fields KeyDown event.
'
' frm - the subform
' KeyCode - the key that was pressed
' strMoveToField - the next parent form field to move to
' booMoveToFirst - should the subform record position be set
to the first record in the subform - default = true
'
' Modified : Squarei Technologies- 03/08/2000
' ----------------------------------------------------- ---
Dim ctl As Control
Dim intRecordCount As Integer

On Error Resume Next
Set ctl = Screen.ActiveControl
If IsComboOpen() = False Then
If ctl.ControlType = acComboBox And (KeyCode = vbKeyDown Or KeyCode =
vbKeyUp) And (InStr(ctl.Tag, "[Ignore_Navigation]") > 0) Then
Exit Function
Else
Select Case KeyCode
Case vbKeyTab, vbKeyReturn, vbKeyDown
If frm.AllowAdditions = True Then
intRecordCount =
frm.RecordsetClone.RecordCount + 1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top