开发者

access: passing variables from vba to sql

i am clicking a button on a form i开发者_JAVA技巧n access:

Private Sub Command29_Click()
some_variable = 2
stDocName = "test"
DoCmd.OpenQuery stDocName
End Sub

my query looks like this:

SELECT *
FROM [some_table]
WHERE [Occurrence Number]=some_variable;

is this possible to do?


AFAIK, the only ways to pass a parameter to a select query and to view the results are:

  1. Update the SQL of the query to include the parameter
  2. Use a form to supply the parameter

In general, option 2 is preferred.

With action queries, you have a lot more options.

EDIT re Comment

SELECT *
FROM [some_table]
WHERE [Occurrence Number]=Forms!SomeOpenForm!SomeControl
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜