Thanks for the feedback.
As far as the GoTo thing is concerned, I rarely use it but though it was the easiest way to accomplish my test.
Thanks again.
I was trying to get something to happen. Each time the code fails, I can see that the query does exist so I was experimenting to find out what would happen if it tried to delete it again.Difficult to be sure when lengthy and nested code can't be tested, but here's what doesn't look right to ,me.
If this is false: If QueryExists(strSheetNameNew) Then
go here: GoTo Replace_Query
which says do this: Delete_Query (strSheetNameNew)
If it doesn't exist, how can you delete it?
The one was a mistake. The move next used to be outside the if statement but I moved it when I added debugging. I'd have realized my screw up if the damn thing wasn't failing before hitting that part, as I'd only get one file produced.Also, I question your placement of RstExport.MoveNext - you will only move if above is TRUE. If not, you are looping while on the same record.
As far as the GoTo thing is concerned, I rarely use it but though it was the easiest way to accomplish my test.
Will work through this, this morning. It's causing problems, so has become my top priority and I don't have to worry about getting sidetracked.@Alc - suggest you research and apply debug.assert to stop the code when about to fail (i.e. before the Debug.Print strSheetNameNew & " does Not Exist" line and thoroughly check all the variables and step through the code at that point.
just in case it is actually the speed of operation causing the issue I would add further doevents between each line of code and see if that resolves the issue
then repeat same query, same data enough times to be sure the problem is solved.
Thanks again.