在白班窗体的成为当前时间中写:
Private Sub Form_Current()
Dim n As Long
Dim i As Long
Dim frm As Form
On Error Resume Next
Set frm = Me.Parent.Child2.Form
n = Me.机床.Value
For i = 1 To frm.RecordsetClone.RecordCount
frm.SelTop = i
If frm.Controls("机床").Value = n Then
frm.SelWidth = 9
Exit For
End If
Next
End Sub
1、在标准模块中写:
Function FindRecord(Myfrm As Form, frm As Form, CtrlName As String)
'参数:Myfrm--当前子窗体
' frm --某个需要查找对应记录的子窗体
' CtrlName --某个两子窗体相同的字段名称
'示例:Call FindRecord(me.Form, Me.Parent.Child2.Form, "机床")
Dim i As Long
For i = 1 To frm.RecordsetClone.RecordCount
frm.SelTop = i
If frm.Controls(CtrlName).Value = Myfrm.Controls(CtrlName).Value Then
frm.SelWidth = frm.Controls.Count / 2
Exit For
End If
Next
End Function
2、在白班窗体中调用函数
Private Sub Form_Current()
On Error Resume Next
Call Call FindRecord(me.Form, Me.Parent.Child2.Form, "机床")
Call Call FindRecord(me.Form, Me.Parent.Child3.Form, "机床")
End Sub
3、中班子窗体中调用函数
Private Sub Form_Current()
On Error Resume Next
Call Call FindRecord(me.Form, Me.Parent.Child1.Form, "机床")
Call Call FindRecord(me.Form, Me.Parent.Child3.Form, "机床")
End Sub
4、夜班子窗体中调用函数
Private Sub Form_Current()
On Error Resume Next
Call Call FindRecord(me.Form, Me.Parent.Child1.Form, "机床")
Call Call FindRecord(me.Form, Me.Parent.Child2.Form, "机床")
End Sub