3
Private Sub OccurrenceName_AfterUpdate()
If OccurrenceName.Value = "Other" Then
    Dim strTechID As String
    Dim strOccurrenceCt As String
    Dim strOccurrenceDate As String

    strTechID = Me.Parent.tbxTechID.Value
    strOccurrenceCt = Forms![frmEmployeeOccurrenceInput]![tbxOccurrence].Value
    strOccurrenceDate = Me.OccurrenceDate.Value

    Dim strOpenArgs As String
    strOpenArgs = strTechID & "|" & strOccurrenceCt & "|" & strOccurrenceDate

    DoCmd.OpenForm "frmOtherOccurrence", , , , , , strOpenArgs
Else
    Me.OccurrenceAmt = Me.OccurrenceName.Column(1)
    Me.Type = Me.OccurrenceName.Column(2)
End If
End Sub

Every time it runs I get "The Open Form action was canceled" with an error code of 2501. The line it gets caught on is the DoCmd.OpenForm call. Debugging give NO additional information.

Here is where the OpenArgs is passed to:

Private Sub Form_Load()

Dim aryOA As Variant

aryOA = Split(Me.OpenArgs, "|")

Me.lblTechID.Caption = aryOA(0)
Me.lblOccurrenceCt.Caption = aryOA(1)
Me.lblOccurrenceDate.Caption = aryOA(2)

End Sub
4

1 回答 1

0

我不知道这是否是您的问题,但是您不能将 OpenArgs 传递给打开的表单,并且打开我的意思是它甚至不能处于编辑模式,应该完全关闭。

否则,表单将打开(将其状态从编辑模式更改为正常)但不会传递任何 OpenArgs,因此 OpenArgs 将为 null 并引发异常。

于 2012-09-20T06:30:23.593 回答