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:
- Update the SQL of the query to include the parameter
- 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
精彩评论