Requiring Subforms with RecordsetClone

B

breeboud

I have the following code on a Save button where I attempt to require data
entry in both of the subforms. However, when I run it it gives me a compile
error: method or data member not found on the "Form" portion of the first If
statement. Not sure why....

Private Sub Save_Click()

Dim OKToSave As Boolean

OKToSave = True

On Error GoTo Err_Save_Click

If Me.frmWorkOrderFunctionCodes.Form.RecordsetClone.RecordCount = 0
Then

MsgBox "Please Enter Relevant Function Codes"
OKToSave = False

End If

On Error GoTo Err_Save_Click

If Me.frmPartInfo.Form.RecordsetClone.RecordCount = 0 Then

MsgBox "Please Enter Part Info"
OKToSave = False

End If

If OKToSave Then

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70

End If

Exit_Save_Click:
Exit Sub

Err_Save_Click:
MsgBox Err.Description
Resume Exit_Save_Click


End Sub
 
G

Guest

replace the dot with a bang

If Me.frmWorkOrderFunctionCodes!Form.RecordsetClone.RecordCount = 0
 
B

breeboud

Thank you for your response. I tried that and it tells me that "the object
doesn't support this kind of method" when I click the Save button. Now this
confuses me for several reasons. The original code I posted worked fine when
the frmWorkOrderFunctionCodes was a single form subform, but now that it is a
datasheet subform I have problems. However the frmPartsInfo subform was
always a datasheet and that portion worked fine and the code for that was the
same. Any further advice would be much appreciated.
 
D

Douglas J. Steele

It's supposed to be .Form, not !Form.

A common issue is that you must refer to the name of the subform control on
the parent form. Depending on how the form was added as a subform, it's
possible that the name of the subform control may be different than the name
of the form being used as a subform.
 
B

breeboud

Yes, you're absolutely right. Could have sworn I checked that but apparently
not. Thank you!
It's supposed to be .Form, not !Form.

A common issue is that you must refer to the name of the subform control on
the parent form. Depending on how the form was added as a subform, it's
possible that the name of the subform control may be different than the name
of the form being used as a subform.
replace the dot with a bang
[quoted text clipped - 49 lines]
 

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