Hi Taraj,
Quote:
|
quote:However I get a can't find field error message on the following:
|
I was able to reproduce your error by misspelling my subform name, though there may be other causes:
Run-time error '2465' : Microsoft Access can't find the field 'fssubChildren' referred to in your expression."
Should the '1' be there in your subform name?
The subform reference syntax is correct. The fully qualified version would be:
set rst = Forms("frmParentForm").Controls("Archive_Sales_Sub form1").Form.RecordsetClone
"Archive_Sales_Subform1" references the subform container control, 'Form' references the actual subform object the subform control contains, and whose properties are exposed. The Controls collection is the default property of the Form object, so it doesn't need to be referenced explicity.
Quote:
|
quote:the button works and checks only the first record on the form.
|
I initially ran my code against a recordset that contained a single record. To iterate through all the records in the subforms recordset use:
' Update sub form field values
With rst
Do Until .EOF
.Edit
!Archive = True
.Update
.MoveNext
Loop
End With
Also, here's a little debugging routine to view the records in your recordset while you're working in the code window:
' Clone the sub form's recordset
Set rst = Me!Archive_Sales_Subform1.Form.RecordsetClone
rst.MoveFirst
' Dump recordset to debug window
Do Until rst.EOF
For Each fld In rst.Fields
Debug.Print fld.Name & vbTab & fld.Value
Next
rst.MoveNext
Loop
rst.MoveFirst ' Return to first record in recordset before processing.
Let me know if this helps.
Bob