Private Sub 删除_Click()
Me.子窗体.SetFocus
Me.子窗体.Form.AllowDeletions = True
DoCmd.RunCommand acCmdDeleteRecord
Me.子窗体.Form.AllowDeletions = False
End Sub
Private Sub 新增_Click()
Me.子窗体.SetFocus
Me.子窗体.Form.AllowAdditions = True
DoCmd.RunCommand acCmdRecordsGoToNew
Me.子窗体.Form!姓名 = "谁?"
Call ReadOrWrite("R")
Me.子窗体.Form.AllowAdditions = False
End Sub
Private Sub 修改_Click()
Call ReadOrWrite("W")
End Sub
Sub ReadOrWrite(str As String)
Dim ctls As Controls
Dim subctls As Controls
Dim subctl As Control
If IsNull(Me.记录号.Value) = True Then Exit Sub
Set ctls = Me.Form.Controls
Set subctls = Me.子窗体.Form.Controls
Me.子窗体.Form.SelTop = Me.记录号.Value
For Each subctl In subctls
If subctl.ControlType = acTextBox Or subctl.ControlType = acComboBox Then
Select Case str
Case "R"
ctls(subctl.Name).Value = subctl.Value
Case "W"
If subctl.Name <> "人员ID" Then
subctl.Value = ctls(subctl.Name).Value
End If
End Select
End If
Next subctl
End Sub