Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do Until EOF

Status
Not open for further replies.

tstrike

Technical User
Jun 17, 2002
44
0
0
US
I am trying to have a delete query run until it gets to the end of the record set, but i Keep geeting the following error when I try to run the code.

Application-defined or object-defined Error

I am using Access XP

Here is the Code

DoCmd.OpenForm "DoubleDupNoAccrual"
'Opens Form for use in deleting double dups with no Invioce
Do Until Forms![DoubleDupNoAccrual].EOF
'Causes this part of the code to repete
DoCmd.OpenQuery "DeleteDblDupNoAccrual"
'Deletes the Double Dups from the Delivery Info Table that have no accrual
DoCmd.GoToRecord acDataForm, "DoubleDupNoAccrual", acNext
'Moves to the next record in the DoubleDupNoAccrual form
Loop
'Tells program to go back up to the do command

Can someone please help me
 
Hi,

Looks to me like you have data on a form, you then delete records via a query (records which are contained within the form), you then go back to the form and expect the form to automatically know that you have removed records from it.

If you are going to use a form to do this (rather than with vb DAO/ADO) then you'd need to refresh the form (and return to the correct last record) before attempting to delete more records.

regards,

Darrylle

"Never argue with an idiot, he'll bring you down to his level - then beat you with experience." darrylles@totalise.co.uk
 
The error occures at the statement:

Do Until Forms![DoubleDupNoAccrual].EOF

I have used forms to do the delete before in a do loop, but I used error handling to run the rest of the programming. I know I seen how to do this somewhere, but do not remember where.
 
Hello,

There is no Form.EOF property, that is why you are getting the error. If this is a process you want to happen for each record as it is processed by the form then you could put your code in the form's OnCurrent event. Alternatively, you could create a command button and put the code in the Click event code. In this case it would only execute if the user clicked the command button.

I hope this helps you and please feel free to post again if you have more questions.

Have a great day!

j2consulting@yahoo.com
 
If I put the do loop in the on open proprty of the form, will the calling modual wait to continue until the form is done runing the delete query?
 
The Open Event of the form is ran before any of the records are displayed while the Load Event is ran after all of the records are displayed. One other difference between the 2 events, Open Event can cancel the openning of the form while the Load Event can not.

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
When the going gets tough, the tough gets going.
 
Thank you for your help every one
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top