1
+ Sub manipulating_Tables()
2
+ On Error Resume Next
3
+ 'INSERT values
4
+ DoCmd.RunSQL "INSERT INTO Facebook(OK, Field1) VALUES ('5', 'Kendall')"
5
+ 'UPDATE field
6
+ DoCmd.RunSQL "UPDATE Facebook SET Field1 = 'Kendall' WHERE ID = 1"
7
+ 'ALTER TABLE
8
+ DoCmd.runSQL "ALTER TABLE X "
9
+ End Sub
10
+
11
+ Sub edit_Table()
12
+ Dim d As DAO.Database
13
+ Dim t As TableDef
14
+ Dim r As DAO.Recordset
15
+
16
+ Set d = CurrentDb
17
+ Set t = d.TableDefs( "..." )
18
+ Set r = t.OpenRecordset(, dbOpenSnapshot)
19
+
20
+ r.Edit
21
+ r(...).Value = "..."
22
+ r.Update
23
+
24
+ Set d = Nothing
25
+ Set t = Nothing
26
+ End Sub
27
+
28
+ 'When field exists, create random number and put to name "Address"
29
+ If Err.Number = 3380 Then
30
+ DoCmd.RunSQL "ALTER TABLE Kendall " & _
31
+ "ADD COLUMN Address" & Int(( 25 - 10 + 1 ) * Rnd + 10 ) & " varchar(255)" & _
32
+ ")"
33
+
34
+ End If
35
+
36
+ Tables
37
+ 1 . "CREATE TABLE x (...[datatype])"
38
+ 2 . "INSERT INTO x (...) VALUES (... [datatype])"
39
+ 3 . "ALTER TABLE x ADD x [datatype]"
40
+ 4 . "ALTER TABLE x DROP x"
41
+ 5 . "UPDATE x SET x = '...'"
42
+ 6 . "UPDATE x SET x = '...' WHERE x = '...' AND x = '...'"
43
+ 7 . "UPDATE x SET x = '...' WHERE x = '...' OR x = '...'"
44
+ 8 . "UPDATE TABLE x ALTER COLUMN x [datatype]"
45
+ 9 . "CREATE TABLE x (...[datatype] NOT NULL UNIQUE)"
46
+ 10 . "CREATE TABLE x (...[datatype] NOT NULL PRIMARY KEY)"
47
+ 11 . ??? Foreign Key
48
+
49
+ Queries
50
+ 1 . Create query - "SELECT x FROM x / SELECT x, y FROM x, y"
51
+ 2 . "SELECT x, y.something FROM x INNER JOIN y ON x.something = y.something"
52
+ 3 . "SELECT x FROM x ORDER BY x"
53
+ 4 . Recordset openRecordSet(sql) / openRecordSet(...)
54
+ 5 . .FINDFIRST, FINDLAST etc. "[fieldname] > x"
55
+ 6 . Record Count
56
+ 7 . Fields
57
+
58
+ DLookup
59
+ DLookup( "[field]" , "table" , "[something]=x" )
60
+
61
+ Filter Forms
62
+ 1 . .filter "[field]=x" / .filterOn = true / false
63
+
64
+ "SELECT CustID, CustName, Product.ProductName " & _
65
+ "FROM Customer " & _
66
+ "INNER JOIN Product ON Customer.CustID = Product.CustomerID"
0 commit comments