01.
Private
Sub
Form_Load()
02.
Data1.Connect =
"access"
03.
Data1.DatabaseName =
"My Documents\Database2.mdb"
04.
End
Sub
05.
06.
07.
Private
Sub
Form_Activate()
08.
Data1.RecordSource =
"select * from data"
09.
Data1.Refresh
10.
If
Not
Data1.Recordset.EOF
Then
<< มันขึ้น ERROR ตรงนี้อ้ะครับ ต้องทพยังไง
11.
With
Data1.Recordset
12.
Text1.Text = !fname
13.
Text2.Text = !lname
14.
Text3.Text = !unumber
15.
Text4.Text = !id
16.
End
With
17.
End
If
18.
End
Sub
19.
20.
21.
Private
Sub
Command3_Click()
22.
Data1.Recordset.AddNew
23.
End
Sub
24.
25.
26.
Private
Sub
Command1_Click()
27.
With
Data1.Recordset
28.
!id = Text4.Text
29.
!fname = Text1.Text
30.
!lname = Text2.Text
31.
!unumber = Text3.Text
32.
.Update
33.
End
With
34.
End
Sub
35.
36.
37.
Private
Sub
Command2_Click()
38.
Data1.RecordSource =
"select * from data where id = "
& Text1.Text &
""
39.
Data1.Refresh
40.
If
Not
Data1.Recordset.EOF
Then
41.
Data1.Recordset.Delete
42.
End
If
43.
End
Sub
44.
45.
46.
Private
Sub
Command4_Click()
47.
Unload
Me
48.
End
49.
End
Sub
50.
51.
52.
Private
Sub
Command5_Click()
53.
Data1.Recordset.Edit
54.
End
Sub
55.
56.
57.
Private
Sub
Command6_Click()
58.
On
Error
GoTo
Err
59.
Data1.Recordset.MovePrevious
60.
If
Not
Data1.Recordset.EOF
Then
61.
With
Data1.Recordset
62.
Text1.Text = !fname
63.
Text2.Text = !lname
64.
Text3.Text = !unumber
65.
Text4.Text = !id
66.
End
With
67.
End
If
68.
Err:
69.
End
Sub
70.
71.
72.
Private
Sub
Command7_Click()
73.
On
Error
GoTo
Err
74.
Data1.Recordset.MoveNext
75.
If
Not
Data1.Recordset.EOF
Then
76.
With
Data1.Recordset
77.
Text1.Text = !fname
78.
Text2.Text = !lname
79.
Text3.Text = !unumber
80.
Text4.Text = !id
81.
End
With
82.
End
If
83.
Err: