我创建了一个make table查询和一个重命名宏,它在创建表后重命名该表。我想创建一个提示输入新表名的对话框。这可能吗?我该怎么做?
答案 0 :(得分:0)
你可能最好使用一个VB子编辑查询def的SQL属性,换句话说,在执行它之前更改make table SQL语句中的tablename,例如:
Public Sub MakeTable()
Dim strNewTableName As String
Dim Qdef As QueryDef
strNewTableName = InputBox("Please enter the table name")
If strNewTableName & "" = "" Then Exit Sub 'No table name has been given
Set Qdef = CurrentDb.QueryDefs("MakeTableQueryName")
Qdef.SQL = "SELECT bla, bla INTO " & strNewTableName & " WHERE etc"
CurrentDb.Execute "MakeTableQueryName"
Set Qdef = Nothing
End Sub
此后无需再运行单独的宏。