David R
I know a few things...
- Local time
- Yesterday, 19:09
- Joined
- Oct 23, 2001
- Messages
- 2,633
This has to rank up there with one of the stupidest problems ever, but I've been staring at it for several hours now and nothing seems to work.
Problem: I want to automatically filter a subform based on the value of a combobox in the main form (switchboard). But I need to filter based on column(1), not .Value
Main form: Switchboard
Field to filter by: comboUserName
RecordSource: tableCitations
Field to filter on: AdminID
Things I have tried:
Problem: I want to automatically filter a subform based on the value of a combobox in the main form (switchboard). But I need to filter based on column(1), not .Value
Main form: Switchboard
Field to filter by: comboUserName
- 4 columns.
- Column 1 is tied to tableStaffing.EmployeeID, Text input, 6 chars.
- None of the columns are zero width.
RecordSource: tableCitations
Field to filter on: AdminID
- Text, 6 chars.
Things I have tried:
- Enabling/Unlocking the comboUserName appears to make no difference.
- I do have Allow Filters turned on.
-
Code:
=[Parent].[Form].[comboUserName].[Column](1)
Code:[tableCitations].[AdminID] = Me.[Parent].[Form].[comboUserName].[Column](1)
Code:[AdminID] = [Parent].[Form].[comboUserName].[Column](1)
Code:"[tableCitations].[AdminID] = '" & [Parent].[Form].[comboUserName].[Column](1) & "'"
- Per http://access.mvps.org/access/forms/frm0031.htm, I tried
Code:
[AdminID] = Forms!Switchboard!comboUserName.Column.(1)
- I have tried filtering on another field with the same content type (Text, 6), and a hardcoded value works fine.
Code:
- Looking at an older database, I gave up on Form Properties and went to VBA. A dummy button with
Code:
Me.Filter = "[AdminID] = '" & Me.Parent.comboUserName.Column.(1) & "'"
Code:Me.Filter = "[AdminID] = '" & Forms!Switchboard!comboUserName.Column(1) & "'"
- OK, so make it automatic the hard way. In the subform
Code:
Private Sub Form_Load() Me.Filter = "[AdminID] = '" & Forms!Switchboard!comboUserName.Column(1) & "'" Me.FilterOn = True End Sub
- So what if we load it from the Switchboard's Load event?
Code:
Private Sub Form_Load() Forms![Switchboard]![subformDrafts].Form.Filter = "[AdminID] = '" & Forms!Switchboard!comboUserName.Column(1) & "' AND CitationMailed Is Null" Forms![Switchboard]![subformDrafts].Form.FilterOn = True End Sub
- :banghead:
I am about ready to tryCode:DLookup("EmployeeID","tableStaffing","EmployeeLogin = '" & Forms!Switchboard!comboUserName & "'"
Last edited: