- VERSION 5.00
- Begin VB.Form Form2
- Caption = "Form2"
- ClientHeight = 4665
- ClientLeft = 13485
- ClientTop = 4020
- ClientWidth = 5430
- LinkTopic = "Form2"
- ScaleHeight = 4665
- ScaleWidth = 5430
- Begin VB.TextBox Text5
- Height = 375
- Left = 2520
- TabIndex = 11
- Top = 2880
- Width = 1455
- End
- Begin VB.CommandButton Command2
- Caption = "取消"
- Height = 495
- Left = 3360
- TabIndex = 9
- Top = 3600
- Width = 1335
- End
- Begin VB.CommandButton Command1
- Caption = "确定"
- Height = 495
- Left = 1200
- TabIndex = 8
- Top = 3600
- Width = 1335
- End
- Begin VB.TextBox Text4
- Height = 375
- Left = 2520
- TabIndex = 7
- Top = 2160
- Width = 1455
- End
- Begin VB.TextBox Text3
- Height = 375
- Left = 2520
- TabIndex = 5
- Top = 1560
- Width = 1455
- End
- Begin VB.TextBox Text2
- Height = 375
- Left = 2520
- TabIndex = 3
- Top = 960
- Width = 1455
- End
- Begin VB.TextBox Text1
- Height = 375
- Left = 2520
- TabIndex = 1
- Top = 480
- Width = 1455
- End
- Begin VB.Label 部门
- Caption = "部门:"
- Height = 375
- Left = 1680
- TabIndex = 10
- Top = 3000
- Width = 615
- End
- Begin VB.Label Label4
- Caption = "职位:"
- Height = 255
- Left = 1680
- TabIndex = 6
- Top = 2280
- Width = 615
- End
- Begin VB.Label Label3
- Caption = "性别:"
- Height = 255
- Left = 1680
- TabIndex = 4
- Top = 1680
- Width = 615
- End
- Begin VB.Label Label2
- Caption = "名字:"
- Height = 255
- Left = 1680
- TabIndex = 2
- Top = 1080
- Width = 735
- End
- Begin VB.Label Label1
- Caption = "编号:"
- Height = 255
- Left = 1680
- TabIndex = 0
- Top = 600
- Width = 615
- End
- End
- Attribute VB_Name = "Form2"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Private Sub Command1_Click() '确定增加记录
- On Error GoTo com1
- '=======================================================================================
- '判断主键是否相同,如果相同则退出
- res.MoveFirst
- Dim head() As String '定义头数组
- Dim temp As Long '
- temp = res.RecordCount - 1
- ReDim head(temp)
- For i = 0 To temp
- head(i) = res.Fields(0)
- res.MoveNext
- If Form2.Text1.Text = head(i) Then
- MsgBox "主键相同,退出"
- Unload Me
- Exit Sub
- End If
- Next i
- '=======================================================================================
- res.AddNew
- res.Fields(0) = Form2.Text1.Text
- res.Fields(1) = Form2.Text2.Text
- res.Fields(2) = Form2.Text3.Text
- res.Fields(3) = Form2.Text4.Text
- res.Fields(4) = Form2.Text5.Text
- res.Update
- Unload Me
- Exit Sub
- com1:
- MsgBox "添加出错"
- Unload Me
- End Sub
- Private Sub Command2_Click()
- Unload Me
- End Sub