如何在Access中的"VBA编辑器"窗口中运行查询?

问题描述:

我想做这样的事情:

DoCmd.OpenQuery "select * from some_table;"

我该怎么做?

请记住,我不想创建一个新查询,将其保存并运行它.我只想在VBA代码中输入select语句并运行它.

Please keep in mind I don't want to create a new query, save it, and run it. I just want to type the select statement in the VBA code and run it.

如果只想获取最大值,则

If you just want to get a max value, the DMax-Function should do the trick:

myVariable = DMax("fee", "courses", "region = 'UK'")

(对应于SELECT MAX(fee) FROM courses WHERE region = 'UK').