我有一个主要形式“属性”,它有两个子表单,其中一个显示该属性中的房间,另一个显示每个房间的占用者。
当您更改属性时,房间会在第一个子表单中更改,这是连续的。当您向下滚动房间子窗体,使新房间处于活动状态时,我希望占用者在第二个子窗体中进行更改。
到目前为止,我已经在“属性”主要形式的当前事件中写了这个:
Dim dblRoomID As Double
dblRoomID = Forms.Properties.frmRoomsByPropertySubform.Form.room_id
成功从第一个子表单中提取Room_ID。
现在我需要使用Room_ID在第二个子窗体中设置过滤器,该子窗体当前显示所有属性的所有占用者,但具有Room_ID字段。
我不能
Forms.Properies.frmStudentsRoomQuickview.Form.Filter = "[Room_ID]=" & dblRoomID
或docmd.applyfilter工作 - 我一直在假设这是因为活动表单需要是'frmstudentRoomQuickview'才能让后者工作 - 但我无法理解为什么只需设置.filter不行。
编辑:我应该添加,我不能在“房间”表格中使用子表格,因为房间形式需要连续。
编辑2:
Private Sub Form_Current()
Dim dblRoomID As Double
If IsNull(Forms.Properties.frmRoomsByPropertySubform.Form.room_id) Then
Forms.Properties.frmRoomsByPropertySubform.Visible = False
Forms.Properties.frmStudentsRoomQuickview.Visible = False
Else
Forms.Properties.frmRoomsByPropertySubform.Visible = True
Forms.Properties.frmStudentsRoomQuickview.Visible = True
dblRoomID = Forms.Properties.frmRoomsByPropertySubform.Form.room_id
Call frmStudentsRoomQuickview_Enter(dblRoomID)
End If
End Sub
Private Sub frmStudentsRoomQuickview_Enter(dblRoomID)
Forms.Properties.frmStudentsRoomQuickview.Filter = "[room_id] = " & dblRoomID
Forms.Properties.frmStudentsRoomQuickview.FilterOn = True
Forms.Properties.frmStudentsRoomQuickview.Requery
Debug.Print Screen.ActiveForm.name
End Sub
我现在得到“程序声明与具有相同名称的事件或程序的描述”错误
答案 0 :(得分:6)
您是否尝试过滤滤镜?
Forms.Properies.frmStudentsRoomQuickview.Form.Filter = "[Room_ID]=" & dblRoomID
Forms.Properies.frmStudentsRoomQuickview.Form.FilterOn = True
修改强>
看过你的更新后,我理解了这个问题。问题是您无法将参数传递给_Enter事件。你必须做这样的事情:
Dim dblRoomID As Double
Private Sub Form_Current()
dblRoomID = 0
If IsNull(Forms.Properties.frmRoomsByPropertySubform.Form.room_id) Then
Me.frmRoomsByPropertySubform.Visible = False
Me.frmStudentsRoomQuickview.Visible = False
Else
Me.frmRoomsByPropertySubform.Visible = True
Me.frmStudentsRoomQuickview.Visible = True
dblRoomID = Me.frmRoomsByPropertySubform.Form.room_id
DoStudentsRoomQuickViewFilter
End If
End Sub
Private Sub DoStudentsRoomQuickViewFilter()
If dblRoomID <> 0 Then
Me.frmStudentsRoomQuickview.Form.Filter = "[Room_ID] = " & dblRoomID
Me.frmStudentsRoomQuickview.Form.FilterOn = True
Me.frmStudentsRoomQuickview.Requery
Debug.Print Screen.ActiveForm.Name
End If
End Sub
Private Sub frmStudentsRoomQuickview_Enter()
DoStudentsRoomQuickViewFilter
End Sub
答案 1 :(得分:1)
检查拼写“属性”......
Forms.Properies.frmStudentsRoomQuickview.Form.Filter = "[Room_ID]=" & dblRoomID
Forms.Properies.frmStudentsRoomQuickview.Form.FilterOn = True