W
Wayne Livingstone
Let me see if I can explain what I'm trying to do:
I have a sub-form that displays as a continuous form so
that I can see all the relevant records in a list format.
On the sub-form I have a "Select" button which opens a new
form. A Select button appears in each record displayed in
the sub-form. The ID field for the sub-form data is
PrintReqSubID from the PrintReq_Sub table.
The form I want to open is PlotSelect and its recordsource
is also the PrintReq_Sub table. I want the PlotSelect form
to open at the same PrintReqSubID as the one where I
clicked the Select button.
I have tried the following code and a few variations but
the PlotSelect form always opens at a new record.
Private Sub Select_Click()
On Error GoTo Err_Select_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "PlotSelect"
If IsNull([PrintSubID]) Then
MsgBox "You must start a new record."
DoCmd.GoToControl "Date"
Else
stLinkCriteria = "[PrintReq_Sub].[PrintSubID]=" &
Forms![PrintRequisition]![PrintReq_Subform]![PrintSubID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
' Me.Visible = False
End If
Exit_Select_Click:
Exit Sub
Err_Select_Click:
MsgBox Err.Description
Resume Exit_Select_Click
End Sub
I have a sub-form that displays as a continuous form so
that I can see all the relevant records in a list format.
On the sub-form I have a "Select" button which opens a new
form. A Select button appears in each record displayed in
the sub-form. The ID field for the sub-form data is
PrintReqSubID from the PrintReq_Sub table.
The form I want to open is PlotSelect and its recordsource
is also the PrintReq_Sub table. I want the PlotSelect form
to open at the same PrintReqSubID as the one where I
clicked the Select button.
I have tried the following code and a few variations but
the PlotSelect form always opens at a new record.
Private Sub Select_Click()
On Error GoTo Err_Select_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "PlotSelect"
If IsNull([PrintSubID]) Then
MsgBox "You must start a new record."
DoCmd.GoToControl "Date"
Else
stLinkCriteria = "[PrintReq_Sub].[PrintSubID]=" &
Forms![PrintRequisition]![PrintReq_Subform]![PrintSubID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
' Me.Visible = False
End If
Exit_Select_Click:
Exit Sub
Err_Select_Click:
MsgBox Err.Description
Resume Exit_Select_Click
End Sub