J
JohnB
Hi. I wonder if anyone can help with this. I have a
Command button on a Subform which currently opens a
linked form. See below for the On Click Event code. I
want to modify this to do two things. First to decide
whether to open a form at all, based on the contents of a
field in the Subform. Second, to decide which of two
forms to open, based on the contents of a field in the
main form.
The first decision would be based on the content of field
txtStage in the Subform. If this reads either ONE or TWO
then the process would stop and a Message Box would be
displayed. For any other content in this field, the
process would move on to step two. This would depend on
the content of field txtSubject, in the main form. If
this reads ECS then form frmGrades1 is opened. For any
other content, form frmGrades2 is opened. For each case,
the link would be as below, PlacementID.
Is this possible and if so, can anyone help with the
additional code needed? Thanks, JohnB
Private Sub CmdGrades_Click()
On Error GoTo Err_CmdGrades_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmGrades1"
stLinkCriteria = "[PlacementID]=" & Me![PlacementID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_CmdGrades_Click:
Exit Sub
Err_CmdGrades_Click:
MsgBox Err.Description
Resume Exit_CmdGrades_Click
End Sub
Command button on a Subform which currently opens a
linked form. See below for the On Click Event code. I
want to modify this to do two things. First to decide
whether to open a form at all, based on the contents of a
field in the Subform. Second, to decide which of two
forms to open, based on the contents of a field in the
main form.
The first decision would be based on the content of field
txtStage in the Subform. If this reads either ONE or TWO
then the process would stop and a Message Box would be
displayed. For any other content in this field, the
process would move on to step two. This would depend on
the content of field txtSubject, in the main form. If
this reads ECS then form frmGrades1 is opened. For any
other content, form frmGrades2 is opened. For each case,
the link would be as below, PlacementID.
Is this possible and if so, can anyone help with the
additional code needed? Thanks, JohnB
Private Sub CmdGrades_Click()
On Error GoTo Err_CmdGrades_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmGrades1"
stLinkCriteria = "[PlacementID]=" & Me![PlacementID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_CmdGrades_Click:
Exit Sub
Err_CmdGrades_Click:
MsgBox Err.Description
Resume Exit_CmdGrades_Click
End Sub