Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 11-09-2019, 09:36 AM   #1
JamiePMortimer
Newly Registered User
 
Join Date: Dec 2016
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
JamiePMortimer is on a distinguished road
Filter Before Date

I'll caveat this with I have zero working knowledge of vba & minimal experience of access.

I have two criteria, I can get it working on the first, so it filters for employee number with a wildcard search and returning everything if the box is blank:

DoCmd.ApplyFilter "", "[Employee Num] Like ""*"" & [Forms]![Emp]![EmpBox] & ""*""

I want to create one if their start date is below a date in the unbound box [Forms]![Emp]![StartDateBox] and will return all employees if the [StartDateBox] is empty.

JamiePMortimer is offline   Reply With Quote
Old 11-09-2019, 09:40 AM   #2
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,721
Thanks: 57
Thanked 1,260 Times in 1,241 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Filter Before Date

Hi Jamie. Welcome to AWF!

The usual approach would have the following syntax:

FieldName = Forms!FormName.ControlName OR Forms!FormName.ControlName Is Null
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
Old 11-09-2019, 10:57 AM   #3
JamiePMortimer
Newly Registered User
 
Join Date: Dec 2016
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
JamiePMortimer is on a distinguished road
Re: Filter Before Date

Thanks for the welcome and response,

Is there a way to integrate the two?

Filter based on the employee number if one is entered and/or the start date if a date is entered?

JamiePMortimer is offline   Reply With Quote
Old 11-09-2019, 11:09 AM   #4
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,721
Thanks: 57
Thanked 1,260 Times in 1,241 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Filter Before Date

Quote:
Originally Posted by JamiePMortimer View Post
Thanks for the welcome and response,

Is there a way to integrate the two?

Filter based on the employee number if one is entered and/or the start date if a date is entered?
Yes, you just have to isolate the two separate conditions using parentheses. For example:
Code:
(DateField = FormReference OR FormReference Is Null) AND (NumberField=FormReference OR FormReference Is Null)
Hope that helps...

__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
BETWEEN date AND date filter in query excludes year in result set yaya Queries 12 12-05-2018 01:33 PM
[SOLVED] Open a form and filter where date is between a date range jjake Forms 5 05-20-2016 08:05 AM
Date filter - If Date is in a future month simon4amiee Queries 2 04-20-2015 04:54 AM
Filter Records: Adding unbound Date listbox to Filter String mactheknife Modules & VBA 2 02-10-2014 08:19 AM
filter table's 3 date fields to same date range dbaldwin Queries 3 05-02-2012 11:36 AM




All times are GMT -8. The time now is 08:03 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World