S
Steven V. Olson
Why does the Set statement not recognize the form objects?
The following subroutine closes an existing Form named
EyeglassPrescriptionForm and opens another form named
Patient Safety RX Order Input Form. A nested subform named
OpthalmicDoctorPrescriptionForm is opened with the main
form, however the subform records are initialized to the
first record, which is not desired.
To solve this problem, a DAO RecordsetClone is created and
Set to match the subform records. However, the form object
is not being recogized in the Set statement. What am I
doing wrong?
Steve Olson
Private Sub Command60_Click()
On Error GoTo Err_Command60_Click
Dim rst As DAO.Recordset
Dim stDocName As String
Dim stLinkCriteria As String
Dim intEyeglassPrescriptionID As Integer
intEyeglassPrescriptionID =
Me.EyeglassPrescriptionForm.Form.EyeglassPrescriptionID
stDocName = "Patient Safety RX Order Input Form"
stLinkCriteria = "[PersonalInformationID]=" & Me!
[PersonalInformationID]
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
'Sets Recordset to [Patient Safety RX Order Input
Form].OpthalmicDoctorPrescriptionForm subform
Set rst =
Me.OpthalmicDoctorPrescriptionForm.Form.RecordsetClone
rst.FindFirst "[EyeglassPrescriptionID] =" &
intEyeglassPrescriptionID
If rst.NoMatch Then
MsgBox "No match was found. Something is
wrong!"
Else
Me.OpthalmicDoctorPrescriptionForm.Form.Bookmark =
rst.Bookmark
End If
rst.Close
Set rst = Nothing
Exit_Command60_Click:
Exit Sub
Err_Command60_Click:
MsgBox Err.Description
Resume Exit_Command60_Click
End Sub
The following subroutine closes an existing Form named
EyeglassPrescriptionForm and opens another form named
Patient Safety RX Order Input Form. A nested subform named
OpthalmicDoctorPrescriptionForm is opened with the main
form, however the subform records are initialized to the
first record, which is not desired.
To solve this problem, a DAO RecordsetClone is created and
Set to match the subform records. However, the form object
is not being recogized in the Set statement. What am I
doing wrong?
Steve Olson
Private Sub Command60_Click()
On Error GoTo Err_Command60_Click
Dim rst As DAO.Recordset
Dim stDocName As String
Dim stLinkCriteria As String
Dim intEyeglassPrescriptionID As Integer
intEyeglassPrescriptionID =
Me.EyeglassPrescriptionForm.Form.EyeglassPrescriptionID
stDocName = "Patient Safety RX Order Input Form"
stLinkCriteria = "[PersonalInformationID]=" & Me!
[PersonalInformationID]
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
'Sets Recordset to [Patient Safety RX Order Input
Form].OpthalmicDoctorPrescriptionForm subform
Set rst =
Me.OpthalmicDoctorPrescriptionForm.Form.RecordsetClone
rst.FindFirst "[EyeglassPrescriptionID] =" &
intEyeglassPrescriptionID
If rst.NoMatch Then
MsgBox "No match was found. Something is
wrong!"
Else
Me.OpthalmicDoctorPrescriptionForm.Form.Bookmark =
rst.Bookmark
End If
rst.Close
Set rst = Nothing
Exit_Command60_Click:
Exit Sub
Err_Command60_Click:
MsgBox Err.Description
Resume Exit_Command60_Click
End Sub