简体   繁体   中英

MS-ACCESS: Filter a table, then display in unbound listbox

In my form Main I am trying to have a push button Search display a few columns from Table into an unbound listbox (located on form Main ) after applying a filter. Initially I was using a ComboBox, but I would like to use a listbox that only displays the names of those who are overdue on training. Below is what I had when using a ComboBox, which worked perfectly.

Private Sub SearchCheck_Click()
Call Search
End Sub

Sub Search()
Dim Task As String

Me.Refresh

Task = "SELECT * FROM Table WHERE DateDiff('m', [Training], Date()) > 24 And [Active Employee] = True"

DoCmd.ApplyFilter Task

End Sub

Surely, I imagine I am missing something that tells it where to place the results? Any ideas? I am rather new to MS-ACCESS.

除非您希望在运行时将列表框RowSource从非过滤列表更改为过滤列表,否则只需在设计中设置RowSource属性即可,而不要使用VBA。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM