点击事件访问表单创建传递查询 [英] access form on click event create pass through query

查看:56
本文介绍了点击事件访问表单创建传递查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张带数字[1、2、3、4、5]列表的访问表.单击一个数字时,我要运行一个直通查询,以打开查询的数据表视图.例如,假设单击了[3],则直通查询将运行

I have an access form with a list of numbers [1, 2, 3, 4, 5]. When a number is clicked on, i want to run a pass through query that opens a datasheet view of the query. So for example, say [3] is clicked, then a pass through query would run SQL like

select * from mytable where number=3  

我必须为此使用VBA吗?如何在VBA中完成?我具有SQL Server的登录信息,但是除了查询表外没有其他权限.

Do I have to use VBA for this? How is it done in VBA? I have the log in information for the SQL server, but no permissions other than querying tables.

推荐答案

使用保存的传递查询和DAO.

Use a saved pass-though query and DAO.

您总共可以执行两行代码.

You can do this for a total of 2 lines of code.

此代码将起作用:

CurrentDb.QueryDefs("MyPass").SQL = "select * from mytable where number = " & Me.Number
DoCmd.OpenQuery "MyPass"

这篇关于点击事件访问表单创建传递查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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