Solved Query based on combo box (1 Viewer)

HealthyB1

Registered User.
Local time
Tomorrow, 06:43
Joined
Jul 21, 2013
Messages
96
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
Tomorrow, 04:13
Joined
May 7, 2009
Messages
19,169
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
Tomorrow, 06:43
Joined
Jul 21, 2013
Messages
96
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
Tomorrow, 06:43
Joined
Jul 21, 2013
Messages
96
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, 20:13
Joined
May 23, 2011
Messages
4,717
Perhaps EmployeeID criteria should be:
[Forms]![Allcrete-Report-Date-Range]![Employee],[EmployeeID] OR IS NULL
 

HealthyB1

Registered User.
Local time
Tomorrow, 06:43
Joined
Jul 21, 2013
Messages
96
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