Do While... Looping through records on a form or RecordsetClone

T

ThriftyFinanceGirl

I need to check each record in a form and create records if none exist in the
child table (transparent to the user)
Below is my code --I know I need to create the Loop but I'm not really sure
how. I just haven't ever had to create records en masse' so I've just never
learned how! Guess it's time!
I've gotten this far, but no luck in 'grabbing' the "Tax ID" value from each
record as we move through the subform. My queries can be modified to use a
function instead of the value from the form, but I still have to grab it and
don't know how to do that through the recordsetclone as I
move through the recordset. Can someone please help me modify this code?

------------------------------------------------------------------
Dim rst As Recordset
Dim intTaxID As Integer

Set rst = Forms!frmworkwithtax.RecordsetClone

Do While Not rst.EOF ' Iterate through each element.
intTaxID = rst.FindNext
If DCount("Taxable", "qryCheckLocObj") < 1 Then
'there are no LocationObjects for this tax
'create them
MsgBox "there are no LocationObjects for Tax " & Forms!
frmworkwithtax.TaxID
DoCmd.OpenQuery "qryAddNewLocationObjects" 'this is an
append query using the taxid number on the form
'check the next record
rst.MoveNext
Else
'there are LocationObjects for this tax
'check the next record
rst.MoveNext
End If
Loop
rst.Close
-----------------------------------------------------------------
 

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