VBA 调用 SelHeight 的代码 属性 子表单的值不起作用 - 语法错误?

VBA code for recalling the SelHeight Property Value of a subform is not working - syntax error?

我的目标:我在表单中有一个子表单,我想获取子表单中用户 selected 记录中一个字段的值,并使用该值填充我表单中的一个字段。我正在使用 .Selheight 来确定子表单中 selected 的记录数。代码是这样的:

    If Me.Frm_ICD10CMCodes.Form.SelHeight = 0 Then
        MsgBox "Please select one record. You have selected " & Me.Frm_ICD10CMCodes.Form.SelHeight & " records.", vbOKOnly, "Dr Talking:"
    ElseIf Me.Frm_ICD10CMCodes.Form.SelHeight = 1 Then
        'Copy the diagnosis in the diagnosis box
    ElseIf Me.Frm_ICD10CMCodes.Form.SelHeight > 1 Then
        MsgBox "Please select only one record.", vbOKOnly, "Dr Talking:"
    End If

现在的问题是,当我 运行 代码时,无论我 select 有多少条记录,Form.SelHeight 属性 一直返回值 0。

我一定是做错了什么。 ,但我没有收到错误。

一旦您离开子表单,所选记录将被取消选择。

这对我有用,有一个主窗体来显示所选记录的数量:

Option Compare Database
Option Explicit


Private Sub Form_Current()

    Me!txtSelected.Value = Me.SelHeight
    
End Sub


Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    
    Me!txtSelected.Value = Me.SelHeight

End Sub


Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

    If Me.NewRecord = True Then
        Me!txtSelected.Value = 0
    Else
        Me!txtSelected.Value = Me.SelHeight
    End If
    
End Sub


Private Sub Form_Open(Cancel As Integer)

    Me.KeyPreview = True

End Sub