我的妻子编写了以下代码,当她的组织使用 Access 2007 时,它曾经对她正常工作。他们刚刚更新到 Access 2010,它不再工作。我对 Access 一点也不熟悉,但我建议我将它呈现给 Stack,看看你们是否可以直接看到在 Access 2010 中不起作用的任何内容。提前感谢您的任何见解。
Private Sub Originating_Zone_AfterUpdate()
Dim EscortDB As DAO.Database
Dim rstBldgs As DAO.Recordset
Set EscortDB = CurrentDb()
Set rstBldgs = EscortDB.OpenRecordset("SELECT BuildingName FROM" & _
" ZoneBldgLookup WHERE ZoneLocation = '" & _
Forms!DateID!EscortIDSubform.Form.[Originating Zone] & _
"' ORDER BY BuildingName", [dbOpenDynaset])
rstBldgs.MoveLast
rstBldgs.MoveFirst
Do Until rstBldgs.EOF
Forms!DateID!EscortIDSubform.Form.[Pick Up Location].AddItem rstBldgs!BuildingName
rstBldgs.MoveNext
Loop
rstBldgs.Close
End Sub
更新:她使用以下代码让它工作。谢谢你的帮助!
Private Sub Originating_Zone_AfterUpdate()
Dim sBuildList As String
sBuildList = ("SELECT BuildingName FROM" & _
" ZoneBldgLookup WHERE ZoneLocation = '" & _
Forms!DateID!EscortIDSubform.Form.[Originating Zone] & _
"' ORDER BY BuildingName")
Forms!DateID!EscortIDSubform.Form.[Pick Up Location].RowSource = sBuildList
Forms!DateID!EscortIDSubform.Form.[Pick Up Location].Requery
End Sub