If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Using and "IF" statement
I am working with a database that uses the following code to sum the weeks
service that an employee works in a given department: =DSum("[WeeksService]","Service Record Query","[EmployeeID]="&[EmployeeID]&"And[DepartmentName]=Current_Department_Name") The code is working fine. However, I have discovered that I need to add some type of "IF" statement so that if the Current Department Name is equal to "Reserves", that it will sum all Departments (not just the Current Department Name). Thanks in advance for your help. -- Judy |
#2
|
|||
|
|||
Using and "IF" statement
hi Judy,
On 09.03.2010 19:09, judyb wrote: =DSum("[WeeksService]","Service Record Query","[EmployeeID]="&[EmployeeID]&"And[DepartmentName]=Current_Department_Name") What is 'Current_Department_Name'? The code is working fine. Hmm, I'm quite sure, that it should throw an error as there are some spaces missing. mfG -- stefan -- |
#3
|
|||
|
|||
Using and "IF" statement
On Tue, 9 Mar 2010 10:09:01 -0800, judyb
wrote: I am working with a database that uses the following code to sum the weeks service that an employee works in a given department: =DSum("[WeeksService]","Service Record Query","[EmployeeID]="&[EmployeeID]&"And[DepartmentName]=Current_Department_Name") The code is working fine. However, I have discovered that I need to add some type of "IF" statement so that if the Current Department Name is equal to "Reserves", that it will sum all Departments (not just the Current Department Name). Thanks in advance for your help. Use an OR in your criterion (fixed up somewhat for readability and accuracy): =DSum("[WeeksService]", "Service Record Query", "[EmployeeID]=" & [EmployeeID] & " And ([DepartmentName] = [Current_Department_Name] OR [Current_Department_Name] = 'Reserves'") This assumes that [Current_Department_Name] is in fact a field in the Service Record Query. If not, please explain where and what it is. -- John W. Vinson [MVP] |
#4
|
|||
|
|||
Using and "IF" statement
"judyb" wrote in message ... I am working with a database that uses the following code to sum the weeks service that an employee works in a given department: =DSum("[WeeksService]","Service Record Query","[EmployeeID]="&[EmployeeID]&"And[DepartmentName]=Current_Department_Name") The code is working fine. However, I have discovered that I need to add some type of "IF" statement so that if the Current Department Name is equal to "Reserves", that it will sum all Departments (not just the Current Department Name). Thanks in advance for your help. -- Judy |
#5
|
|||
|
|||
Using and "IF" statement
"judyb" wrote in message
... I am working with a database that uses the following code to sum the weeks service that an employee works in a given department: =DSum("[WeeksService]","Service Record Query","[EmployeeID]="&[EmployeeID]&"And[DepartmentName]=Current_Department_Name") The code is working fine. However, I have discovered that I need to add some type of "IF" statement so that if the Current Department Name is equal to "Reserves", that it will sum all Departments (not just the Current Department Name). Thanks in advance for your help. -- Judy |
#6
|
|||
|
|||
Using and "IF" statement
"judyb" wrote in message ... I am working with a database that uses the following code to sum the weeks service that an employee works in a given department: =DSum("[WeeksService]","Service Record Query","[EmployeeID]="&[EmployeeID]&"And[DepartmentName]=Current_Department_Name") The code is working fine. However, I have discovered that I need to add some type of "IF" statement so that if the Current Department Name is equal to "Reserves", that it will sum all Departments (not just the Current Department Name). Thanks in advance for your help. -- Judy |
#7
|
|||
|
|||
Using and "IF" statement
"jhall2microsoft.com" wrote in message ... "judyb" wrote in message ... I am working with a database that uses the following code to sum the weeks service that an employee works in a given department: =DSum("[WeeksService]","Service Record Query","[EmployeeID]="&[EmployeeID]&"And[DepartmentName]=Current_Department_Name") The code is working fine. However, I have discovered that I need to add some type of "IF" statement so that if the Current Department Name is equal to "Reserves", that it will sum all Departments (not just the Current Department Name). Thanks in advance for your help. -- Judy |
Thread Tools | |
Display Modes | |
|
|