G
Guest
I have a main form with a subform. Each has its own table. They are not
linked. My aim is to stop at each subform record and run MakeChanges(),
which processes all the records in the main form table.
My immediate problem is that when intTick = 2 and MakeChanges() starts its
second run, the final GoToRecord command begins to advance the SUBFORM
pointer rather than the main form pointer. Then intTick2, which should go to
950, quickly exceeds intCount, which = 12.
I am self-taught in Access, so my overall coding may be clumsy. If you want
to offer a superior strategy, I'd welcome that, too.
==========================
Private Sub Label22_Click()
intCount = CurrentDb.OpenRecordset("AddrFixTbl").RecordCount '= 12
intCount2 = CurrentDb.OpenRecordset("ANDIAddrTbl").RecordCount '= 950
intTick = 1
While intTick <= intCount
With Forms!UpdateAddrsPt2.UpdateAddrsSubform.Form
strTxt2Fix = !AddrBadTxt
strFix = !AddrTxtFix
strLoc = !AddrBadTxtLoc
End With
MakeChanges
Me.UpdateAddrsSubform.SetFocus 'Focus on AddrFixTbl (subform)
DoCmd.GoToRecord , , acNext
intTick = intTick + 1
Wend
End Sub
----------------------------------
Private Sub MakeChanges()
Me.Form.SetFocus 'Focus on ANDIAddrTbl (main form)
intTick2 = 1 'Now on Record 1 in ANDIAddrTbl
While intTick2 <= intCount2
' If strLoc... Then
' DO STUFF IN HERE...
' End If
If intTick2 < intCount2 Then
DoCmd.GoToRecord , , acNext
End If
intTick2 = intTick2 + 1
Wend
DoCmd.GoToRecord , , acFirst 'CRASHES HERE WHEN intTick = 2 & intTick2
= 12
End Sub
==================================
Thanks.
David
linked. My aim is to stop at each subform record and run MakeChanges(),
which processes all the records in the main form table.
My immediate problem is that when intTick = 2 and MakeChanges() starts its
second run, the final GoToRecord command begins to advance the SUBFORM
pointer rather than the main form pointer. Then intTick2, which should go to
950, quickly exceeds intCount, which = 12.
I am self-taught in Access, so my overall coding may be clumsy. If you want
to offer a superior strategy, I'd welcome that, too.
==========================
Private Sub Label22_Click()
intCount = CurrentDb.OpenRecordset("AddrFixTbl").RecordCount '= 12
intCount2 = CurrentDb.OpenRecordset("ANDIAddrTbl").RecordCount '= 950
intTick = 1
While intTick <= intCount
With Forms!UpdateAddrsPt2.UpdateAddrsSubform.Form
strTxt2Fix = !AddrBadTxt
strFix = !AddrTxtFix
strLoc = !AddrBadTxtLoc
End With
MakeChanges
Me.UpdateAddrsSubform.SetFocus 'Focus on AddrFixTbl (subform)
DoCmd.GoToRecord , , acNext
intTick = intTick + 1
Wend
End Sub
----------------------------------
Private Sub MakeChanges()
Me.Form.SetFocus 'Focus on ANDIAddrTbl (main form)
intTick2 = 1 'Now on Record 1 in ANDIAddrTbl
While intTick2 <= intCount2
' If strLoc... Then
' DO STUFF IN HERE...
' End If
If intTick2 < intCount2 Then
DoCmd.GoToRecord , , acNext
End If
intTick2 = intTick2 + 1
Wend
DoCmd.GoToRecord , , acFirst 'CRASHES HERE WHEN intTick = 2 & intTick2
= 12
End Sub
==================================
Thanks.
David