我需要在基于当前记录的表单中设置特定下拉列表的记录源,即当我单击下一条记录时,记录源应该更新。
但是我无法找到这样做的任何事件。这需要在不添加任何额外/新按钮的情况下完成。
我尝试使用“Form Current”事件,但显然它只在表单加载时被触发一次,而不是在我移动到同一表单中的下一条记录时。
有什么建议吗?
示例代码:
Private Sub Form_Current()
MsgBox ("hello")
Dim strSQL As String
strSQL = "SELECT DISTINCTROW StudentTeachingStatusTbl.ID, StudentTeachingStatusTbl.SuccessStatus FROM StudentTeachingStatusTbl WHERE Active = -1" & _
"or ID IN (Select SuccessID from StudentTeachingExperiencesTbl where StuId = " & Me.Text2.Value
If Not IsNull(Me.StudentTeachExp_SubF.Controls("SemesterID")) Then
strSQL = strSQL & " and SemesterID = " & Me.StudentTeachExp_SubF.Controls("SemesterID").Value
End If
strSQL = strSQL & ")"
Me.StudentTeachExp_SubF.Controls("SuccessID").RowSource = strSQL
End Sub
答案 0 :(得分:2)
" On Current"当表单关注新记录时触发事件。 打开表单时会发生这种情况,因为表单上有记录。
" On Load"和" On Open"打开表格时会触发一次。
尝试将MsgBox添加到" On Current"用于测试目的的事件代码。
祝你好运。
答案 1 :(得分:0)
查看您的代码,您正在更改子表单记录源,那么您是否更改子表单或主表单上的记录?
如果它是子表单,则需要使用子表单OnChange事件,而不是父表单事件。