Filter Before Date (1 Viewer)

JamiePMortimer

New member
Local time
Today, 06:41
Joined
Dec 2, 2016
Messages
2
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.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:41
Joined
Oct 29, 2018
Messages
21,454
Hi Jamie. Welcome to AWF!

The usual approach would have the following syntax:

FieldName = Forms!FormName.ControlName OR Forms!FormName.ControlName Is Null
 

JamiePMortimer

New member
Local time
Today, 06:41
Joined
Dec 2, 2016
Messages
2
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?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:41
Joined
Oct 29, 2018
Messages
21,454
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...
 

Users who are viewing this thread

Top Bottom