0

I know how to create a Query though Query Design (manually)

enter image description here

but how to create a "Query" with command? i am looking for something like

Create Query [Query_Name] 
As
Select * from Table1

Can anyone post me the code snippet that can do something like this?

Things i have TRIED

  1. Erik von Asmuth's solution : The below query

    CREATE PROCEDURE MyQuery [@Param1] Integer; SELECT * FROM SalesInvoice WHERE SalesInvoice.S_Id = [@Param1]

gave the following error

enter image description here

0

1 Answer 1

1

You can use the PROCEDURE command. Since Access doesn't have stored procedures, that just creates a query.

E.g.:

PROCEDURE MyQuery
[@Param1] Integer;
SELECT *
FROM MyTable
WHERE MyTable.ID = [@Param1]

The use case is pretty limited, since queries are usually created through VBA using the CurrentDb.CreateQueryDef method.

Sign up to request clarification or add additional context in comments.

4 Comments

i have tried it and it didnt work, for more detail see the updated question
You haven't executed it through ADO, which is necessary for it to work
can you please explain how to do that?
Search VBA help for CREATE PROCEDURE, it has an example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.