现在假设数据表窗体,窗体1名为form1,窗体2名为form2,form1和form2中,共同有Lable1,Lable2,Lable3,Lable4,Lable5,其中以Lable1为依据,其它4个值从form1传到form2,在form2中写入代码
Public Sub Lable1_BeforeUpdate(Cancel As Integer)
If [Forms]![form1]![Lable1] = [Forms]![form2]![Lable1] Then
[Forms]![form1]![Lable2] = [Forms]![form2]![Lable2]
End If
If [Forms]![form1]![Lable1] = [Forms]![form2]![Lable1] Then
[Forms]![form1]![Lable3] = [Forms]![form2]![Lable3]
End If
If [Forms]![form1]![Lable1] = [Forms]![form2]![Lable1] Then
[Forms]![form1]![Lable4] = [Forms]![form2]![Lable4]
End If
If [Forms]![form1]![Lable1] = [Forms]![form2]![Lable1] Then
[Forms]![form1]![Lable5] = [Forms]![form2]![Lable5]
End If
End Sub
现在的问题是,在form2中输入和form1中相同的Lable1的时候,form1中的光标必须在form1中Lable1对应的记录行,才能传值,如何解决这个问题,
Public Sub Lable1_BeforeUpdate(Cancel As Integer)
If [Forms]![form2]![Lable1] = [Forms]![form1]![Lable1] Then
[Forms]![form2]![Lable2] = [Forms]![form1]![Lable2]
End If
If [Forms]![form2]![Lable1] = [Forms]![form1]![Lable1] Then
[Forms]![form2]![Lable3] = [Forms]![form1]![Lable3]
End If
If [Forms]![form2]![Lable1] = [Forms]![form1]![Lable1] Then
[Forms]![form2]![Lable4] = [Forms]![form1]![Lable4]
End If
If [Forms]![form2]![Lable1] = [Forms]![form1]![Lable1] Then
[Forms]![form2]![Lable5] = [Forms]![form1]![Lable5]
End If
End Sub