Run queries made by code

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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).
 
Back
Top