you can loop through the recordset of a subform using the previous format
which I posted. Replace 'Me' with the name of the subform. Then use the
recordset as normal (looping, modifying, deleting).
Dim rstMeForm As DAO.Recordset
Set rstMeForm = Me.Recordset
Another method you could use would be a query. Create a query which does
what you want it to do and place a valid SSN in the criteria row on the
query. When you get the query to work then View the SQL and copy it to your
code, replacing the temporary SSN with the SSN from your form (e.g. [ssn]).
You'll have to make sure the SSN field is interpreted.
If you want to delete records you will do something like
DoCmd.RunSQL "DELETE * FROM [FileName] WHERE [SSN]=" & [SSN]
This format works for action queries only, not select queries.
HTH,
James
redrover said:
Yes, I do want to do this programmatically. There's probably a better way to
do what I need to do but I'm working with a previously designed database. I
have a form that accesses the subform (actually there's a subform within the
subform that is opened). The subform within the subform has the data that I
need to manipulate. The data on the forms are keyed by SSN. The subform
data I want to loop through is the incidences for a SSN. If the data is a
certain type and is at least a year old, I want to delete it. I also need to
total the data for the various types. Can I do this from the main form with
an 'On Open' or 'On Focus' event by declaring the subform data and looping
through it there? Either way, I need to delete some records and bring the
calculated data back into the main form and use it there.
Thanks for any guidance you can give me.