M
medirate
I need to move to a control(txtDIA) located in a nested subform. The nested
subform (subPatient) is located inside subform subPatientInfo, which is
located inside frmPatientInfo. I open frmPatientInfo by closing another
form, frmNotes.
frmPatientInfo, has the following properties:
Name Source
Object
Main form: frmPatientInfo
Sub form: subPatientInfo fsubPatientInfo
Nested in subform: subPatient fsubPatient
So on the on Close event for frmNotes, I have the following code:
Private Sub Form_Close()
Dim frm1 As Form
Dim frm2 As Form
Dim rst1 As Recordset
Dim rst2 As Recordset
DoCmd.OpenForm "frmPatientInfo", , , "[fldCompanyID]= " &
Me![Retain_CompanyID], acFormPropertySettings, acWindowNormal
Set frm1 = Forms!frmPatientInfo!subPatientInfo.Form
Set frm2 = Forms!frmPatientInfo!subPatientInfo.Form!SubPatient.Form
Set rst1 = frm1.Recordset
Set rst2 = frm2.Recordset
With rst1
.FindFirst "fldPatientID = " & Me.Retain_PatientID
If .NoMatch Then
MsgBox "Could not locate the Patient ID number"
Else
frm1.Bookmark = rst1.Bookmark
End If
End With
With rst2
..FindFirst "fldLossID = " & Me.Retain_LossId
If .NoMatch Then
MsgBox "Could not locate the Loss Id number"
Else
frm2.Bookmark = rst2.Bookmark
End If
End With
Forms!frmPatientInfo!subPatientInfo.Form!SubPatient.SetFocus
Forms!frmPatientInfo!subPatientInfo.Form!SubPatient!txtDIA.SetFocus
End Sub
When frmNotes closes, frmPatientInfo opens up fine and dandy, but the focus
will not move to the txtDIA control on the nested subform. Instead, the
focus remains in the Main form. There are no errors generated.
I've also tried setting the focus by referring to the nested subform as
'frm2.SetFocus' right after 'frm2.Bookmark' in the above code, but this
generated "Error 244: There is an invalid method in the expression".
How can I move the focus to the txtDIA control once the form is opened?
Thanks!
subform (subPatient) is located inside subform subPatientInfo, which is
located inside frmPatientInfo. I open frmPatientInfo by closing another
form, frmNotes.
frmPatientInfo, has the following properties:
Name Source
Object
Main form: frmPatientInfo
Sub form: subPatientInfo fsubPatientInfo
Nested in subform: subPatient fsubPatient
So on the on Close event for frmNotes, I have the following code:
Private Sub Form_Close()
Dim frm1 As Form
Dim frm2 As Form
Dim rst1 As Recordset
Dim rst2 As Recordset
DoCmd.OpenForm "frmPatientInfo", , , "[fldCompanyID]= " &
Me![Retain_CompanyID], acFormPropertySettings, acWindowNormal
Set frm1 = Forms!frmPatientInfo!subPatientInfo.Form
Set frm2 = Forms!frmPatientInfo!subPatientInfo.Form!SubPatient.Form
Set rst1 = frm1.Recordset
Set rst2 = frm2.Recordset
With rst1
.FindFirst "fldPatientID = " & Me.Retain_PatientID
If .NoMatch Then
MsgBox "Could not locate the Patient ID number"
Else
frm1.Bookmark = rst1.Bookmark
End If
End With
With rst2
..FindFirst "fldLossID = " & Me.Retain_LossId
If .NoMatch Then
MsgBox "Could not locate the Loss Id number"
Else
frm2.Bookmark = rst2.Bookmark
End If
End With
Forms!frmPatientInfo!subPatientInfo.Form!SubPatient.SetFocus
Forms!frmPatientInfo!subPatientInfo.Form!SubPatient!txtDIA.SetFocus
End Sub
When frmNotes closes, frmPatientInfo opens up fine and dandy, but the focus
will not move to the txtDIA control on the nested subform. Instead, the
focus remains in the Main form. There are no errors generated.
I've also tried setting the focus by referring to the nested subform as
'frm2.SetFocus' right after 'frm2.Bookmark' in the above code, but this
generated "Error 244: There is an invalid method in the expression".
How can I move the focus to the txtDIA control once the form is opened?
Thanks!