I'm trying to change pass-through queries using code - but for some reason I can only 'see' the queries I'm trying to alter some of the time - other times I can see them and change their QueryDefs("qryName"
.Sql property - which is the real goal here. Is there something I'm missing - shouldn't I be able to manipulate pass-through queries just as I would a normal Access query?
I also tried refering to the query using
Application.DBEngine(0).Databases(0).QueryDefs("qryname"
but that also gave inconsistent results.
Here's what I'm attempting:
strSQL = "Select * From dbo.ASQLServer2000Table"
'Delete "qryTemp" if it exists
For Each qdf In Application.DBEngine(0).Databases(0).QueryDefs
If qdf.Name = "qryTemp" Then
Application.DBEngine(0).Databases(0).QueryDefs.Delete (qdf.Name)
End If
Next qdf
'create a temp passthrough query from an existing passthrough - this is the only way I could tink to do it...
DoCmd.CopyObject , "qryTemp", acQuery, "qryPassThroughTemplateSave" 'qryPassThroughTemplateSave is a passthrough template
'add the strSQL to the passthrough we just created
Application.DBEngine(0).Databases(0).QueryDefs("qryTemp"
.SQL = strSQL
'since I need to make a table, create a qry to put it into a table.
DoCmd.RunSQL ("Select * INTO tbl01A030_AllDataForTopCategories_MD FROM qryTemp;"
Sorry about the spacing for the above...
I get errors saying that "qryTemp" is not found at the line where I look to add the .sql code.
Any help would be greatly appreciated - I'm definately missing something!
I also tried refering to the query using
Application.DBEngine(0).Databases(0).QueryDefs("qryname"
Here's what I'm attempting:
strSQL = "Select * From dbo.ASQLServer2000Table"
'Delete "qryTemp" if it exists
For Each qdf In Application.DBEngine(0).Databases(0).QueryDefs
If qdf.Name = "qryTemp" Then
Application.DBEngine(0).Databases(0).QueryDefs.Delete (qdf.Name)
End If
Next qdf
'create a temp passthrough query from an existing passthrough - this is the only way I could tink to do it...
DoCmd.CopyObject , "qryTemp", acQuery, "qryPassThroughTemplateSave" 'qryPassThroughTemplateSave is a passthrough template
'add the strSQL to the passthrough we just created
Application.DBEngine(0).Databases(0).QueryDefs("qryTemp"
'since I need to make a table, create a qry to put it into a table.
DoCmd.RunSQL ("Select * INTO tbl01A030_AllDataForTopCategories_MD FROM qryTemp;"
Sorry about the spacing for the above...
I get errors saying that "qryTemp" is not found at the line where I look to add the .sql code.
Any help would be greatly appreciated - I'm definately missing something!