CreateQueryDef() pause needed
-
I appreciate the assistance that all of you have provided so far. However, I have encountered a slight glitch with the CreateQueryDef() method. The problem is that it seems to take a while for the QueryDef to be actually created and available for use in the following code. After I create a QueryDef, I need to use it in the very next subroutine, a point in which it might not actually become available in MS Access. Is there a way to pause execution of the subroutine until the QueryDef is actually created and available for use?
-
I appreciate the assistance that all of you have provided so far. However, I have encountered a slight glitch with the CreateQueryDef() method. The problem is that it seems to take a while for the QueryDef to be actually created and available for use in the following code. After I create a QueryDef, I need to use it in the very next subroutine, a point in which it might not actually become available in MS Access. Is there a way to pause execution of the subroutine until the QueryDef is actually created and available for use?
I've not tried this... Perhaps something like:
CreateQueryDef("mynewquery",...)
while( notexists( "mynewquery" ) )
doevents
loopqdf = QueryDefs("mynewquery")
Those are not the right names, but maybe the right idea. Let us know if you get a solution. I may want to use it myself. David
-
I've not tried this... Perhaps something like:
CreateQueryDef("mynewquery",...)
while( notexists( "mynewquery" ) )
doevents
loopqdf = QueryDefs("mynewquery")
Those are not the right names, but maybe the right idea. Let us know if you get a solution. I may want to use it myself. David
Here is what I did, and interestingly enough...it works. I created code that essentially does nothing but execute a loop and pass a counter to a control. Then I added a control to the form, left it visible, but essentially hid it from the form by making the textbox's background color, border color, and fore color the exact same as the underlying form color. This provided something for the processor to do while the QueryDef was being created. I essentially needed to count to 10000. Here is the code:
'Provides time to create QueryDef qryFinalResult Dim intCount As Integer intCount = 0 For intCount = 1 To 10000 txtCounter.SetFocus txtCounter.Text = "Count: " & intCount & "." intCount = intCount + 1 Next
Does anybody have a more elegant way to do this? This code prevents that error message from coming up indicating that the QueryDef that I had just created does not exist. When I step through the code myself, the processor has enough time to create the QueryDef object, but when I run it as an application, it does not have time to create it in time to use it.