?? form4.frm
字號:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "msadodc.ocx"
Begin VB.Form Form4
Caption = "錄入"
ClientHeight = 9090
ClientLeft = 60
ClientTop = 450
ClientWidth = 11220
LinkTopic = "Form4"
ScaleHeight = 9090
ScaleWidth = 11220
StartUpPosition = 3 'Windows Default
Begin MSAdodcLib.Adodc Adodc1
Height = 615
Left = 8160
Top = 6120
Visible = 0 'False
Width = 2535
_ExtentX = 4471
_ExtentY = 1085
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.TextBox txtFields
DataField = "ID"
DataSource = "datPrimaryRS"
Height = 285
Index = 0
Left = 2280
TabIndex = 11
Top = 600
Width = 3735
End
Begin VB.CommandButton Command2
Caption = "清除"
Height = 495
Left = 6480
TabIndex = 10
Top = 600
Width = 975
End
Begin MSAdodcLib.Adodc Adodc2
Height = 330
Left = 8280
Top = 7320
Visible = 0 'False
Width = 1815
_ExtentX = 3201
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc2"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.Frame Frame3
Caption = "添加"
Height = 2535
Left = 7560
TabIndex = 6
Top = 600
Width = 3375
Begin VB.CommandButton Command6
Caption = "開始添加"
Height = 495
Left = 240
TabIndex = 9
Top = 240
Width = 1695
End
Begin VB.CommandButton Command1
Caption = "確認添加"
Height = 495
Left = 240
TabIndex = 8
Top = 1440
Width = 1695
End
Begin VB.CommandButton Command3
Caption = "結(jié)束添加"
Height = 495
Left = 240
TabIndex = 7
Top = 840
Width = 1695
End
End
Begin VB.Frame Frame2
Caption = "即時修改"
Height = 2295
Left = 7560
TabIndex = 0
Top = 3360
Width = 3375
Begin VB.CommandButton Command5
Caption = "執(zhí)行修改"
Enabled = 0 'False
Height = 495
Left = 360
TabIndex = 5
Top = 1080
Width = 2535
End
Begin VB.CommandButton Command4
Caption = ">|"
Height = 495
Index = 3
Left = 2520
TabIndex = 4
Top = 360
Width = 375
End
Begin VB.CommandButton Command4
Caption = "->"
Height = 495
Index = 2
Left = 1680
TabIndex = 3
Top = 360
Width = 855
End
Begin VB.CommandButton Command4
Caption = "<-"
Height = 495
Index = 1
Left = 840
TabIndex = 2
Top = 360
Width = 855
End
Begin VB.CommandButton Command4
Caption = "|<"
Height = 495
Index = 0
Left = 360
TabIndex = 1
Top = 360
Width = 495
End
End
Begin VB.Label lblLabels
Caption = "姓名:"
Height = 255
Index = 0
Left = 360
TabIndex = 12
Top = 600
Width = 1815
End
End
Attribute VB_Name = "Form4"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim id As String
Dim cMAx As Integer
Dim flagEdit As Boolean
Private Sub Command1_Click()
'每一次確認,都會為下一次準備繼續(xù)
'防止出錯誤!
flagEdit = True
Command5.Enabled = False
On Error GoTo AddErr
'一種保護
Command5.Enabled = False
'數(shù)據(jù)庫操作
Adodc1.Refresh
Adodc1.Recordset.AddNew
For i = 0 To cMAx - 1
Adodc1.Recordset.Fields(i) = Trim(txtFields(i).Text)
Next i
Adodc1.Recordset.Update
'新一輪的添加
'生成新id
Dim DIindex As Integer
For i = 0 To cMAx - 1
If Trim(lblLabels(i)) = "ID" & ":" Then
idindex = i
End If
Next
'清除
id = txtFields(idindex).Text
For i = 0 To cMAx - 1
txtFields(i).Text = ""
Next i
id = Val(id) + 1
txtFields(idindex).Text = id
GoTo sss
AddErr:
MsgBox Err.Description
sss:
End Sub
Private Sub Command2_Click()
For i = 0 To cMAx - 1
txtFields(i).Text = ""
Next i
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Command4_Click(Index As Integer)
'前后移動記錄
With Adodc1.Recordset
Select Case Index
Case 0:
If Not .BOF Then .MoveFirst
If .BOF Then .MoveFirst
Case 1:
If .RecordCount > 0 Then
If Not .BOF Then .MovePrevious
If .BOF Then .MoveFirst
End If
Case 2:
If .RecordCount > 0 Then
If Not .EOF Then .MoveNext
If .EOF Then .MoveLast
End If
Case 3:
If .RecordCount > 0 Then
If Not .EOF Then .MoveLast
If .EOF Then .MoveLast
End If
End Select
End With
'顯示一下
For i = 0 To cMAx - 1
If Adodc1.Recordset.Fields(i) <> "" Then
txtFields(i).Text = Trim(Adodc1.Recordset.Fields(i))
End If
Next i
Command5.Enabled = True
End Sub
Private Sub Command5_Click()
On Error GoTo e
For i = 0 To cMAx - 1
Adodc1.Recordset.Fields(i) = Trim(txtFields(i).Text)
Next i
Adodc1.Recordset.Update
'Adodc1.Refresh
GoTo X
e:
MsgBox Err.Description
X:
End Sub
Private Sub Command6_Click()
'開始添加操作
'一種保護
Command5.Enabled = False
'清除顯示
For i = 0 To cMAx - 1
txtFields(i).Text = ""
Next i
'得到推薦的id
If id = 0 Then
Adodc1.RecordSource = "select id from tblC "
Adodc1.Refresh
a = Adodc1.Recordset.Fields(0)
txtFields(1).Text = Val(a) + 1
Else
txtFields(1).Text = Val(id)
End If
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from tblXUESHENG "
Adodc1.Refresh
End Sub
Private Sub Form_Load()
Dim a As Integer
Me.Left = (Screen.Width - Me.Width) / 2 + 150 '使窗體居中
Me.Top = (Screen.Height - Me.Height) / 2 + 100
flagEdit = False
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\招聘信息.mdb;Persist Security Info=False"
'生成錄入的序號
Adodc1.RecordSource = "select id from tblC "
Adodc1.Refresh
a = Val(Adodc1.Recordset.Fields(0))
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from tblXUESHENG "
Adodc1.Refresh
'防止出錯誤!
Command5.Enabled = False
Adodc2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\招聘信息.mdb;Persist Security Info=False"
Adodc2.RecordSource = "select c from tblC "
Adodc2.Refresh
cMAx = Adodc2.Recordset.Fields(0)
Adodc2.RecordSource = "select 名稱 from tblCol "
Adodc2.Refresh
'為了大小一至
lblLabels(0).Top = txtFields(0).Top
lblLabels(0).Height = txtFields(0).Height
lblLabels(0).Caption = Trim(Adodc2.Recordset.Fields(0)) & ":"
'if trim(Adodc2.Recordset.Fields(0))="ID"
Dim i As Integer
For i = 1 To cMAx - 1
Load txtFields(i)
txtFields(i).Left = txtFields(i - 1).Left
txtFields(i).Top = txtFields(i - 1).Top + txtFields(i - 1).Height + 25
txtFields(i).Visible = True
'
Load lblLabels(i)
lblLabels(i).Left = lblLabels(i - 1).Left
lblLabels(i).Top = lblLabels(i - 1).Top + lblLabels(i - 1).Height + 25
Adodc2.Recordset.MoveNext
lblLabels(i).Caption = Adodc2.Recordset.Fields(0) & ":"
lblLabels(i).Visible = True
Next
For i = 0 To cMAx - 1
If Trim(lblLabels(i)) = "ID" & ":" Then
txtFields(i).Text = a + 1
End If
Next
End Sub
Private Sub Form_Unload(Cancel As Integer)
If flagEdit Then
Dim i As Integer
Dim id As String
Dim DIindex As Integer
For i = 0 To cMAx - 1
If Trim(lblLabels(i)) = "ID" & ":" Then
idindex = i
End If
Next
id = txtFields(idindex).Text
'id=id-1
'不用這一句 每一批的添加序號都會空出一個!
Adodc1.RecordSource = "select id from tblC "
Adodc1.Refresh
Adodc1.Recordset.Fields(0) = Trim(id)
Adodc1.Recordset.Update
End If
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -