Recently I had to build a monster stack of union queries that were all based on a single query (query1). In this case I had to have two different versions of query1 for different purposes. So I needed to rename a query. To do these two renames is simple in vba
currentdb.QueryDefs("query1").Name = "queryY"
currentdb.QueryDefs("queryX").Name = "query1"