If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Filter Datasheet based on Combo Box selection
I have a SubForm that displays in Datasheet view. I want to add a Combo Box
just above the SubForm that the user can select the Pay_Period_Ending_Date, and once selected I would like the Datasheet to filter based on this date. Can someone please direct me as to how I can do this? -- Message posted via http://www.accessmonster.com |
#2
|
|||
|
|||
Filter Datasheet based on Combo Box selection
Pasadena-D -
You can put your combobox in the header section of the subform. Then based on the selection in the combobox, you can apply your filter like this (using your fieldnames and combobox name). If the user will click on an item, you can put this in the Click event of the combobox: DoCmd.ApplyFilter , "[DateFieldName] = #" & Me.ComboboxName.Column(0) & "#" -- Daryl S "Pasadena-D via AccessMonster.com" wrote: I have a SubForm that displays in Datasheet view. I want to add a Combo Box just above the SubForm that the user can select the Pay_Period_Ending_Date, and once selected I would like the Datasheet to filter based on this date. Can someone please direct me as to how I can do this? -- Message posted via http://www.accessmonster.com . |
#3
|
|||
|
|||
Filter Datasheet based on Combo Box selection
Daryl....This is what I did based on your feedback:
- ComboBox64 - OnClick - [Event Procedure] - Microsoft Visual Basics Code: Private Sub Combo64_Click() DoCmd.ApplyFilter , "[Pay_Period_Ending] = #" & Me.Combo64.Column(1) & "#" End Sub If Combo64 is unbound, then I get a "Run-Time Error '2491": The action or method is invalid because the form or report isn't bound to a table or query". If I bound it to the same query as the SubForm, then it will not let me type a date nor select one from the list. Sorry for not fully understanding this whole thing. -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/201003/1 |
#4
|
|||
|
|||
Filter Datasheet based on Combo Box selection
Pasadena-D -
That is because the combo box is in the parent form instead of the subform. You can put the combo box in the header of the subform instead of outside the subform. Otherwise you will need to set the Filter property of the subform like this (instead of the DoCmd): Me.subformName.Form.Filter = "[Pay_Period_Ending] = #" & Me.Combo64.Column(1) & "#" -- Daryl S "Pasadena-D via AccessMonster.com" wrote: Daryl....This is what I did based on your feedback: - ComboBox64 - OnClick - [Event Procedure] - Microsoft Visual Basics Code: Private Sub Combo64_Click() DoCmd.ApplyFilter , "[Pay_Period_Ending] = #" & Me.Combo64.Column(1) & "#" End Sub If Combo64 is unbound, then I get a "Run-Time Error '2491": The action or method is invalid because the form or report isn't bound to a table or query". If I bound it to the same query as the SubForm, then it will not let me type a date nor select one from the list. Sorry for not fully understanding this whole thing. -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/201003/1 . |
Thread Tools | |
Display Modes | |
|
|