A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Filter Datasheet based on Combo Box selection



 
 
Thread Tools Display Modes
  #1  
Old March 2nd, 2010, 12:39 AM posted to microsoft.public.access.forms
Pasadena-D via AccessMonster.com
external usenet poster
 
Posts: 9
Default 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  
Old March 2nd, 2010, 02:40 PM posted to microsoft.public.access.forms
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default 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  
Old March 2nd, 2010, 09:56 PM posted to microsoft.public.access.forms
Pasadena-D via AccessMonster.com
external usenet poster
 
Posts: 9
Default 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  
Old March 3rd, 2010, 02:40 PM posted to microsoft.public.access.forms
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:02 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.