K
Kurt
I am having trouble referring to a control on my form
from the subform.
When a user clicks a command button called "New" on the
main form (frmMain) a new record is called (code below).
When the user tries to enter the subform (fsubResponse),
I'd like a message to pop up to remind the user to do
something (but only for new records).
The code I put in the On Enter event of the subform is
obviously not written correctly, because the user gets
this message when he tries to enter the subform:
"The expression you entered has an invalid
reference to the Parent property."
Any ideas? Thank you! - Kurt (code below)
--------------------------
ON ENTER CODE FOR SUBFORM
--------------------------
Private Sub fsubResponses_Enter()
'When user attempts to enter responses, tell user
'to record the Patient ID that was assigned
If Me.Parent.NewRecord Then
MsgBox "STOP! Before proceeding, record the Patient
ID - the number in the yellow box -" & vbCrLf & _
"in the ID box on the actual survey. Click OK when
you are ready to move on.", 0, "Patient ID"
End If
End Sub
----------------------------------------
----------------------------
CLICK CODE FOR "NEW" BUTTON
----------------------------
Private Sub cmdNew_Click()
On Error GoTo Err_cmdNew_Click
DoCmd.GoToRecord , , acNewRec
Exit_cmdNew_Click:
Exit Sub
Err_cmdNew_Click:
MsgBox Error$
Resume Exit_cmdNew_Click
End Sub
-----------------------------------
from the subform.
When a user clicks a command button called "New" on the
main form (frmMain) a new record is called (code below).
When the user tries to enter the subform (fsubResponse),
I'd like a message to pop up to remind the user to do
something (but only for new records).
The code I put in the On Enter event of the subform is
obviously not written correctly, because the user gets
this message when he tries to enter the subform:
"The expression you entered has an invalid
reference to the Parent property."
Any ideas? Thank you! - Kurt (code below)
--------------------------
ON ENTER CODE FOR SUBFORM
--------------------------
Private Sub fsubResponses_Enter()
'When user attempts to enter responses, tell user
'to record the Patient ID that was assigned
If Me.Parent.NewRecord Then
MsgBox "STOP! Before proceeding, record the Patient
ID - the number in the yellow box -" & vbCrLf & _
"in the ID box on the actual survey. Click OK when
you are ready to move on.", 0, "Patient ID"
End If
End Sub
----------------------------------------
----------------------------
CLICK CODE FOR "NEW" BUTTON
----------------------------
Private Sub cmdNew_Click()
On Error GoTo Err_cmdNew_Click
DoCmd.GoToRecord , , acNewRec
Exit_cmdNew_Click:
Exit Sub
Err_cmdNew_Click:
MsgBox Error$
Resume Exit_cmdNew_Click
End Sub
-----------------------------------