G
Guest
Hi
I have a function designed to provide new values for PupilID field where
there are duplicates. It works fine until I add the Do...Loop.
With the loop I get an object required error for the counter.
Any ideas please on fixing this error.
I've also tried using a recordset to run the function but then got an
endless loop!
--------------------------------
Function UpdateNewGuestPupilID() As Integer
On Error GoTo UpdateNewGuestPupilID_Err
Dim counter As Integer
' qryCountDuplicateGuestPupilID
DoCmd.OpenQuery "qryCountDuplicateGuestPupilID", acViewNormal, acEdit
counter = [qryCountDuplicateGuestPupilID]!CountOfPupilID
Do Until counter < 2
' Find duplicates for GuestPupilUPN
DoCmd.OpenQuery "Find duplicates for GuestPupilUPN", acViewNormal, acEdit
' qryCheckMaxGuestPupilID
DoCmd.OpenQuery "qryCheckMaxGuestPupilID", acViewNormal, acEdit
' qryLastGuestPupilDuplicatePupilID
DoCmd.OpenQuery "qryLastGuestPupilDuplicatePupilID", acViewNormal, acEdit
' qryUpdateLastGuestPupilID
DoCmd.OpenQuery "qryUpdateLastGuestPupilID", acViewNormal, acEdit
' qryUpdateLastGuestPupil
DoCmd.OpenQuery "qryUpdateLastGuestPupil", acViewNormal, acEdit
counter = counter - 1
Loop
UpdateNewGuestPupilID_Exit:
Exit Function
UpdateNewGuestPupilID_Err:
MsgBox Error$
Resume UpdateNewGuestPupilID_Exit
End Function
I have a function designed to provide new values for PupilID field where
there are duplicates. It works fine until I add the Do...Loop.
With the loop I get an object required error for the counter.
Any ideas please on fixing this error.
I've also tried using a recordset to run the function but then got an
endless loop!
--------------------------------
Function UpdateNewGuestPupilID() As Integer
On Error GoTo UpdateNewGuestPupilID_Err
Dim counter As Integer
' qryCountDuplicateGuestPupilID
DoCmd.OpenQuery "qryCountDuplicateGuestPupilID", acViewNormal, acEdit
counter = [qryCountDuplicateGuestPupilID]!CountOfPupilID
Do Until counter < 2
' Find duplicates for GuestPupilUPN
DoCmd.OpenQuery "Find duplicates for GuestPupilUPN", acViewNormal, acEdit
' qryCheckMaxGuestPupilID
DoCmd.OpenQuery "qryCheckMaxGuestPupilID", acViewNormal, acEdit
' qryLastGuestPupilDuplicatePupilID
DoCmd.OpenQuery "qryLastGuestPupilDuplicatePupilID", acViewNormal, acEdit
' qryUpdateLastGuestPupilID
DoCmd.OpenQuery "qryUpdateLastGuestPupilID", acViewNormal, acEdit
' qryUpdateLastGuestPupil
DoCmd.OpenQuery "qryUpdateLastGuestPupil", acViewNormal, acEdit
counter = counter - 1
Loop
UpdateNewGuestPupilID_Exit:
Exit Function
UpdateNewGuestPupilID_Err:
MsgBox Error$
Resume UpdateNewGuestPupilID_Exit
End Function