Query works but with errors?

agehoops

Registered User.
Local time
Today, 23:04
Joined
Feb 11, 2006
Messages
351
I've got a number of different append and delete queries running on command on one of my forms, in which it makes a copy of all of the data on that form and included subforms, copies them into another table, and then deletes all of the data from that record. When this runs, I get an error saying "record deleted" and then another error message. Now it is deleting the records and it is moving them, however when i go onto one of the subforms, all the fields in the subform show "Deleted#" until i go back to the previous record or forward to the next, then they clear, but everytime it brings up the other error message it says "end or Debug" which I don't want it doing.

Is this the query? Or the coding?

Thanks
 
AgeHoops,

I'd say that the best course of action would be for you to requery at least your main form
after you run your queries. If you are using the Master-Child relationships, then you
probably don't have to explicitly Requery your subforms.

The message is probably resulting from some code on your subform(s) referencing a field value
(which is now deleted) and seeing Nulls.

Wayne
 
Yea think that's exactly what it's doing. But i've just added

Code:
Me.Form.Requery

after each query, and then removed them and added it after all the queries ran and with that in there, it is still giving me the same error (different subform each time) but it's just not deleting them at all with that in :(
 
Hoops,

You're getting a flat-out error right?
What line of code is highlighted if you choose DEBUG?

What is/are the RecordSource of the subform(s)?

You might have to explicitly do (from the main form):

Me.YourSubform.Requery

Wayne
 
Yea. It's weird though because the errors produced aren't always the same one (I assume it is depending on what records exist)

The error will either be that it cannot edit the record because it has been deleted by another user (not possible as i'm the only one currently on the system) so it's weird, then when it goes into Debug, it is highlighting one of the "OnCurrent" event lines of code for that subform it is giving me an error on.

Then there are other times where it just gives me an error saying "record deleted" as well as the other error.

Confusing :(
 
It sounds like you have code trying to modify a record you just deleted.
 
Well i've got a lot of code which is set to clear set the values of the fields to nil if certain conditions are met, and this code is run on the OnCurrentRecord event, and this is the code that is highlighted, but surely it is only running this when it goes back to another record after deleting one?
 
Hey guys thanks for the help. Turns out it was nothing to do with the queries at all, was coding from something else (another problem) that now is solved, which has solved this problem :)

Thanks for all the help
 

Users who are viewing this thread

Back
Top Bottom