Run queries made by code

G

Guest

Dear Access experts,
I would like to create few select queries by VBA. Run them and see result when a user clicks a button (I must do this because the queries must be 100% correct and the Access Queries can be modified by everyone since no user level security is set).

Sample:

Private Sub cmdTest_Click()
Dim strSQL As String
strSQL = "Select * FROM Customers;"
' ... Any idea????
End Sub

Ari A.
 
A

Allen Browne

Sub CreateQueryDAO()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef

Set db = CurrentDb()
Set qdf = db.CreateQueryDef("MyQuery")
qdf.SQL = "SELECT * FROM Customers;"

Set qdf = Nothing
Set db = Nothing
End Sub


--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Ari A said:
Dear Access experts,
I would like to create few select queries by VBA. Run them and see result
when a user clicks a button (I must do this because the queries must be 100%
correct and the Access Queries can be modified by everyone since no user
level security is set).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top