View Full Version : modify a command query with VBA


Eureka
07-08-2007, 01:19 AM
hi all, sometime i need to modify a query and i use this code or something like this:

------------------------
newStrSQL= new sql code

strQryName = "QueryName"
Set cat = New ADOX.Catalog
cat.ActiveConnection = CurrentProject.Connection
Set cmd = New ADODB.Command
Set cmd = cat.Views(strQryName).Command
cmd.CommandText = newStrSQL
Set cat.Views(strQryName).Command = cmd

Set cmd = Nothing
Set cat = Nothing
--------------------------

but now i'm tring to modify a command query but i can't do it with this code because he give me error :mad: , in the debug mode i have seen that in the cat views variable there isn't my query name...
i don't know what i can do please help me