主窗体:
Private Sub 折让_DblClick(Cancel As Integer)
'请在OpenArgs参数中,用,号分割主窗体、子窗体控件、控件名称
Dim Ctlname As String
Ctlname = Screen.ActiveControl.Name
DoCmd.OpenForm "myCalc", , , , , , Me.Form.Name & "," & Ctlname
End Sub
子窗体:
Private Sub 数量_DblClick(Cancel As Integer)
'请在OpenArgs参数中,用,号分割主窗体、子窗体控件、控件名称
Dim Ctlname As String
Ctlname = Screen.ActiveControl.Name
DoCmd.OpenForm "myCalc", , , , , , Me.Parent.Form.Name & "," & Me.Form.Name & "," & Ctlname
End Sub
myCalc窗体:
Private Sub 等于_Click()
Dim str As String
Dim Pfname As String
Dim Sfname As String
Dim Cname As String
On Error GoTo 等于_Err
If IsNull(Me.计算.Value) = False Then
Me.计算.Value = Eval(Me.计算.Value)
Else
Me.计算.SetFocus
Exit Sub
End If
If OpenArgs <> "" Then
str = OpenArgs
Pfname = Mid(str, 1, InStr(1, str, ",") - 1)
str = Replace(str, Pfname & ",", "")
If InStr(1, str, ",") = 0 Then
Sfname = Pfname
Cname = str
Forms(Sfname).Form.Controls(Cname).Value = Me.计算.Value
Else
Sfname = Mid(str, 1, InStr(1, str, ",") - 1)
str = Replace(str, Sfname & ",", "")
Cname = str
Forms(Pfname).Controls(Sfname).Form.Controls(Cname).Value = Me.计算.Value
End If
DoCmd.Close acForm, "myCalc"
End If
等于_Exit:
Exit Sub
等于_Err:
Me.计算.Value = "兄弟,搞错了吧?!^o^ "
Resume 等于_Exit
End Sub
Private Sub L0_Click()
Me.计算.Value = Me.计算.Value & Me.L0.Caption
End Sub
。。。。。
(VBA基础-相关文章技巧链接): Access非常简单实用的计算器 作者: luhao 时间: 2009-3-26 19:51