IIF statement in a DSUM

  • Thread starter Thread starter Gus
  • Start date Start date
G

Gus

Hi,

I have the following code in a form to limit the addition
of a field:

'SBB Less Old Jobs
Dim SBBInstallOJ As Double
Dim SBBRMROJ As Double
SBBInstallOJ = DSum
("[Install]", "tblSalesbwBranch", "[DateEntered] < #01-Apr-
02#")
SBBRMROJ = DSum
("[RMR]", "tblSalesbwBranch", "[DateEntered] < #01-Apr-
02#")
txtInstallOJS.Value = SBBInstallOJ
txtRMROJS.Value = SBBRMROJ

On this form I now must allow for two people and am trying
to add an IIF statement in so that I can select a persons
name from a combo box (there will never be more than two
names in this) on the same form (frmBonus). In
the "SBBInstallOJ" line to add this statement but it
doesn't work.

SBBInstallOJ = IIF(cboSalesManagerName = John Doe, DSum
("[Install]", "tblSalesbwBranch", "[DateEntered] < #01-Apr-
02#", DSum("[Install]", "tblSalesbwBranch", "[DateEntered]
< #01-Jun-04#",))

Any help would be greatly appreciated.

Thanks in advance,

Gus
 
Gus

What error message do you receive, if any?

Have you reviewed the syntax needed for the DSum() function?

I believe you need to use delimiters around "John Doe" (like I just did!).

If you are working in code anyway, another approach would be:

If cboX = "John Doe" Then
SBBInstallOJ = DSum(...)
Else
SBBInstallOJ = DSum(...)
End If
 
Your IIF condition should read like this:
cboSalesManagerName = "John Doe"
not this (as you have it):
cboSalesManagerName = John Doe

HTH
- Turtle
 
Back
Top