‘查詢1=“Select * from 表1 where 性別='男'”
Sub 修改查詢1()
SQL = "select * from 表1 where 性別='女'"
CurrentDb.QueryDefs("查詢1").SQL = SQL
End Sub
Sub 在查詢1的基礎上創建查詢2()
SQL = "select * from 查詢1 where 班級='1班'"
Set 創建查詢 = CurrentDb.CreateQueryDef("查詢2", SQL)
Access.Application.RefreshDatabaseWindow
End Sub
來源:B站 孫興華 ACCESS VBA 查詢篇