Referring to control on form from subform

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
-----------------------------------
 
S

Sandra Daigle

Hi Kurt,

fsubResponses_Enter() is actually a procedure in the main form's class
module, therefore "me" refers to the main form.

Just change the test to:

If Me.NewRecord then
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top