UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Filtering A Datasheet With 2 Different Scenarios, Access 2013    
 
   
AaronDigital
post May 19 2017, 01:32 PM
Post#1



Posts: 13
Joined: 1-May 17



I'm trying to build a button that filters the datasheet portion of my split form. It needs to show two types of records:

1. [MP Done], but not [Mailing Done]
2. Anything not [Mailing Done] that has a [Date Mail] of today or prior.


I'm really struggling with the VBA code. These are the best filters I could manage to piece together. The first one works, the second one doesn't; I'd like for both of them to filter at the same time, giving the the aforementioned desired results.


Me.Filter = "[Mailing Done]=False AND [MP Done]=True"
Me.Filter = "[Date Mail]= Between Date() and Date()-999 & [Mailing Done]=False"

This post has been edited by AaronDigital: May 19 2017, 01:37 PM
Go to the top of the page
 
ScottGem
post May 19 2017, 01:40 PM
Post#2


UtterAccess VIP / UA Clown
Posts: 32,161
Joined: 21-January 04
From: LI, NY


First a split form uses the same recordset. So you can't filter the datasheet view without filtering the form view.

Your first filter looks fine.

The second one should be

"[Mailing Done] = False AND [Date Mail NSOL] <= #" & Date() & "#"


--------------------
Scott <>
Scottgem's Blog
Microsoft Access MVP since 2007
Author: Microsoft Office Access 2007 VBA
Go to the top of the page
 
AaronDigital
post May 19 2017, 01:58 PM
Post#3



Posts: 13
Joined: 1-May 17



Thanks, and sorry for trouble but how can I get them on the same line? This just causes the form to go completely blank


Private Sub Command173_Click()
Me.Filter = "[Mailing Done]=False AND [MP Done]=True"
Me.Filter = "[Mailing Done] = False AND [Date Mail NSOL] <= #" & Date & "#"
Me.FilterOn = True
Me.Requery
End Sub
Go to the top of the page
 
kfield7
post May 19 2017, 04:33 PM
Post#4



Posts: 743
Joined: 12-November 03
From: Conroe, TX


Try me.filter = (first filter) OR (second filter)
Go to the top of the page
 
ScottGem
post May 19 2017, 06:26 PM
Post#5


UtterAccess VIP / UA Clown
Posts: 32,161
Joined: 21-January 04
From: LI, NY


Try:

Private Sub Command173_Click()
Me.Filter = "[Mailing Done]=False AND [MP Done]=True AND [Date Mail NSOL] <= #" & Date & "#"
Me.FilterOn = True

End Sub

--------------------
Scott <>
Scottgem's Blog
Microsoft Access MVP since 2007
Author: Microsoft Office Access 2007 VBA
Go to the top of the page
 
tina t
post May 19 2017, 10:22 PM
Post#6



Posts: 5,169
Joined: 11-November 10
From: SoCal, USA


QUOTE
It needs to show two types of records:

1. [MP Done], but not [Mailing Done]
2. Anything not [Mailing Done] that has a [Date Mail] of today or prior.

the code Scott posted will filter for records that meet all three criteria. if that's what you need, you should be good to go.

if you need to filter for records that meet the first set of criteria, OR the second set of criteria, then the expression will need to be a little bit different, as

"[Mailing Done]=False AND ([MP Done]=True OR [Date Mail NSOL] <= #" & Date & "#)"

i'm not sure how we got from [Date Mail] to [Date Mail NSOL], so i'll just say: use whatever field name is correct.

hth
tina

--------------------
"you can't take the sky from me"
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    20th October 2017 - 05:48 AM