-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathQueries.vb
41 lines (32 loc) · 808 Bytes
/
Queries.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Sub dynamic_Query_SQL()
'
' This sub dynamically programatically modifies a query
'
Dim db As DAO.Database
Set db = CurrentDb
'Sets query
Dim qdf As QueryDef
Set qdf = db.QueryDefs("Google")
'SQL string filter query
Dim string_SQL As String
string_SQL = "SELECT * " & _
"FROM Table1 " & _
"WHERE [Cible1] = 'Paul'"
'Run
qdf.SQL = string_SQL
'Open
'DoCmd.OpenQuery "Google"
Set qdf = Nothing
Set db = Nothing
End Sub
Sub creating_Query()
'
' This sub creates a query
'
Dim db As DAO.Database
Set db = CurrentDb
Dim qdf As DAO.QueryDef
Dim newSQL As String
newSQL = "Select * From [Google] WHERE [Cible2]>'2010'"
Set qdf = db.CreateQueryDef("tempQry", newSQL)
End Sub