SparkyP
asked on
Filter Combobox
I currently use a query with forms!databaselogin!UserNa me as criteria to filter only records applicable to the current user.
Can this filter be applied using VBA
Can this filter be applied using VBA
Yes. Please provide the access db or the table names with sample data. please also indicate where to filter the data (which form).
Me.combo.rowsource= "select field from table where username='" & forms!formname!textboxname &"'"
Not sure if this is what you were asking but you cannot filter a combo through vba like you can with a form or report.
There is no Filter property so you have to set the rowsource property as a whole.
There is no Filter property so you have to set the rowsource property as a whole.
ASKER
mbizup
To the resue again!
The combo is on a subform, so where would I put your code?
To the resue again!
The combo is on a subform, so where would I put your code?
It depends...
How and when do you want to filter the combo?
If you wanted to do this immediately when the main form opens, you would include it in the Open Event of the main form with your other filter statements. You would have to adjust the code a little to point to the combo on the subform:
How and when do you want to filter the combo?
If you wanted to do this immediately when the main form opens, you would include it in the Open Event of the main form with your other filter statements. You would have to adjust the code a little to point to the combo on the subform:
Me.SubformControlName.Form.ComboName.Rowsource= "select field from table where username='" & forms!databaselogin!UserName &"'"
Also is this subform on the databaselogin form, or on a seperate form? If it is on databaselogin, then you dont need the full form reference as a prefix for UserName.
ASKER
Me.WorksheetSub.Form.JobLo okup.Rowso urce= "select field from table where EngName='" & forms!databaselogin!UserNa me &"'"
I feel I understand most of the code except
Rowsource= "select field from table where
I assume table should be replaced with my lookup table, but what else.
Sorry.
I feel I understand most of the code except
Rowsource= "select field from table where
I assume table should be replaced with my lookup table, but what else.
Sorry.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Mbizup
How good are you!!
Thanks once again and have a good weekend
How good are you!!
Thanks once again and have a good weekend
You're very welcome :-)