gpt4 book ai didi

ms-access - Access VBA :How to get input in forms and use them in queries

转载 作者:行者123 更新时间:2023-12-04 07:11:04 25 4
gpt4 key购买 nike

你好

我有一个带有几个按钮的表单。每个按钮运行几行代码。代码中也有查询,例如“select * from table where number =6”

现在,如果我想在表格中输入数字作为输入,我该怎么做。

最佳答案

  • 在按钮附近添加一个未绑定(bind)的文本控件。
  • 更新您的按钮代码以生成查询字符串:

    "SELECT * FROM myTable WHERE myNumber ="& me.controls("myControlName").value
  • 您可能觉得需要确保“myControlName”控件只允许数字/不接受空值,或者在您的过程中处理所有情况

  • myQuery = "SELECT * FROM myTable"
    If Isnull(me.controls("myControlName").value) then
    Else
    If isnumeric(me.controls("myControlName").value) then
    myQuery = myQuery & " WHERE myNumber =" & me.controls("myControlName").value
    Else
    msgBox me.controls("myControlName").value & " is not accepted"
    Exit function
    Endif
    Endif

    关于ms-access - Access VBA :How to get input in forms and use them in queries,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/333318/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com