如何在Access中的"VBA编辑器"窗口中运行查询? [英] How to run a query from the VBA Editor window in Access?

查看:220
本文介绍了如何在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').

这篇关于如何在Access中的"VBA编辑器"窗口中运行查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆