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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stepping thro my code makes it work?!

Status
Not open for further replies.

BigOrangeMonkey

Programmer
Aug 27, 2002
26
0
0
GB
Hi,

I am using the following code to set the ReturnsRecords value of my PassThrough QueryDefs to false, when I step through the code using the debugger it works fine, but when I let the program run without stepping through it doesnt work! Any Ideas because this is really driving me up the wall!

Code :
Code:
Private Sub SetReturnsRecords()
Dim Linkdb As Database
Dim PTQuery1 As QueryDef
Dim PTQuery2 As QueryDef
Dim PTQuery3 As QueryDef
Dim PTQuery4 As QueryDef

    Set Linkdb = OpenDatabase(Application.CurrentProject.FullName)
    
    Set PTQuery1 = Linkdb.QueryDefs("Truncate QLS-LAD Tables")
    Set PTQuery2 = Linkdb.QueryDefs("Update U_Version")
    Set PTQuery3 = Linkdb.QueryDefs("uversion_ladlearningaim_1")
    Set PTQuery4 = Linkdb.QueryDefs("uversion_ladlearningaim_2")
    
    PTQuery1.ReturnsRecords = False
    PTQuery2.ReturnsRecords = False
    PTQuery3.ReturnsRecords = False
    PTQuery4.ReturnsRecords = False
        
End Sub
 
If the database is Access, and if you are inserting records, you could look at this. thread709-229140

There are various other threads on the same topic with dire warnings from people. Works for me though. Peter Meachem
peter @ accuflight.com

 
Pete,
I've seperated out the code to only run the segment I presented earlier, if I let it run by itself the queries do not get the ! symbol next to them to show they are non row returning, if I debug through they do. I will try popping in a delay but I'm not certain this will work as there is a fair bit of processing going on before I use the queries I am trying to set to Non Row Returning, a refresh does nowt!

This "little Glitch" is the only thing preventing me from releasing the software, I'm getting ready to just trap the error, test if its the one that says "A Row Returning querie returned no Rows" and ignoring it (I.e. Only worry if its a different error) but I dont like this style of programming!!

I'm off work until Monday now as the temptation of a Motorbike Event has distracted me from Access... Thankfully as its making me go Bananas and I dont think I could take another day of bashing my head on my screen!!!

Cheers,
Steve.
 
Not sure whether it's relevant but I would set all objects to Nothing before exiting the procedure. This should release the memory occupied by those objects and in this case might just force the links to be updated.

Ken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top