myName = GetmyName() ' gets the name of sheet starting with 'Data' For e.g. sheet name can be 'Data-20150205'
myName = "[" & myName & "$]"
rs.Open " SELECT [State] FROM myName WHERE (([Country]='United States') AND ([Capital]='Boston')) ", cn, adOpenKeyset, adLockReadOnly
这里我收到一个错误,它无法找到myName,其中它实际上是其中一个工作表。请更正
答案 0 :(得分:3)
myName是可变的,你需要像下面这样使用它:
rs.Open " SELECT [State] FROM " & myName & " WHERE (([Country]='United States') AND ([Capital]='Boston')) ", cn, adOpenKeyset, adLockReadOnly