Currently I'm working on formEmployee.
It contains a listbox which contains all the employees, and fields for the employee details which populate by the selection in the listbox.
The listbox (listEmployee) has a query rowsource (qryEmployees).
There is a checkbox (checkCurrent) that I want to control whether the listbox shows all the employee records or only shows the current employee records.
Ideally I'd like it to modify the query, but based on other info I've found, I'm currently using an AfterUpdate to modify the rowsource of the listbox to switch between two similar queries, qryEmployees which has all records, and qryCurrentEmployee which only has current employees (determined by a yes/no field in tblEmployees that is or is not filtered in the query.
The issue I'm having is the syntax of the If/Then statement. I'm not refering to the query correctly. See below:
Expand|Select|Wrap|Line Numbers
- Private Sub checkCurrent_AfterUpdate()
- ' Update listEmployee RowSource based on selection in checkCurrent
- ' to show all employees or only current employees
- If checkCurrent = True Then
- listEmployee.RowSource = qryCurrentEmployee
- Else
- listEmployee.RowSource = qryEmployee
- End If
- End Sub
And are there other suggestions for how I ought to do this better than I am?
I'm new to VBA, having squeaked past VB over ten years ago in junior college, and narrowly failed C. But my currenct position will benefit from my getting much better and more comfortable with VBA. So a final question is: What references do you prefer (websites, books, etc) for your own VBA knowledge?