Solved Query based on combo box (1 Viewer)

HealthyB1

Registered User.
Local time
Today, 11:15
Joined
Jul 21, 2013
Messages
82
I am having a mental blank
I am trying to pull payroll records in a query based on a popup form that asks the user to enter StartDate, EndDate and EmployeeName
The employee field on the form
is based on a combo box tied to the employee file which brings back fields EmpID and Employee Name
As coded it works perfectly so I can records for employee from 1 to N and get their records for the date period specified.
However if the user doesn't select an employee name i would like to bring back all records for all employees for the time period specified.
I assume it is based on the employeename field or EmpId being null but I seem to have problem coding this in my query. Does anyone have a suggestion or a pointer to a query where this has been done?


Query problem.PNG
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 09:45
Joined
May 7, 2009
Messages
16,788
you can add 1 criteria for EmployeeID and JobDay:

for EmployeeID:
Nz([Forms]![Allcrete-Report-Date-Range]![Employee],[EmployeeID])


for JobDay:
Between Nz([Forms]![Allcrete-Report-Date-Range]![Beginning-Date],#01/01/1890#) And Nz([Forms]![Allcrete-Report-Date-Range]![Ending-Date],#31/12/9999#)
 

HealthyB1

Registered User.
Local time
Today, 11:15
Joined
Jul 21, 2013
Messages
82
Thanks for replying ARNLGP
This what I received back after installing the code. The date picking works well standalone but the employee selection is not working
1616304796331.png
 

HealthyB1

Registered User.
Local time
Today, 11:15
Joined
Jul 21, 2013
Messages
82
Thanks for replying ARNLGP
This what I received back after installing the code. The date picking works well standalone but the employee selection is not working
View attachment 90131
Hi arnlgp,

Many thanks I simply prefixed the field name with the table name and the problem was solved. Thanks ever so much.
 

bob fitz

AWF VIP
Local time
Today, 02:45
Joined
May 23, 2011
Messages
4,455
Perhaps EmployeeID criteria should be:
[Forms]![Allcrete-Report-Date-Range]![Employee],[EmployeeID] OR IS NULL
 

HealthyB1

Registered User.
Local time
Today, 11:15
Joined
Jul 21, 2013
Messages
82
Hi Bob,
Thanks for your input.
I used the following which directly referenced the correct table:-

Nz([Forms]![Allcrete-Report-Date-Range]![Employee],[WorkOrder Labor]![EmployeeID])
 

Users who are viewing this thread

Top Bottom