IF, THEN type statement??

  • Thread starter Thread starter KenF
  • Start date Start date
K

KenF

My goal is to print an invoice (using a Report based on a
Search Query). I have a true/false field in the table &
query (Basic Service Call = yes or no). How can I run one
set of calculations in the Query if the Basic Service Call
= yes and a different set of calculations if the Basic
Service Call = no? I am also selecting only one record
based on the key identifier of the record I want to print.

If that logic is not possible, how is the best way to
print differet invoices based on a) selected key
identifier for the record and b) if Basic Service Call =
yes or no?

Thank you.
 
NOTE: I am writig this database in Access 97 (will later
use it on a computer with Offic XP version). Thanks
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You can use the IIf() function in the SELECT clause. E.g.:

SELECT IIf([Basic Service Call]=True,a+b) As TrueSvcCall,
IIf([Basic Service Call]=False,a-b*c) As FalseSvcCall
FROM TableName
WHERE [Basic Service Call] Is Not Null

You could also put in a WHERE criteria that would ensure there are
values in the a, b & c columns (or whatever you are using to
calculate). Or you could use the Nz() function to prevent NULLs in
the calculations, which will return a NULL for the result.

Nz(a,0) + Nz(b,0)

HTH,

MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQBGISYechKqOuFEgEQKX3gCdErARv9zJedYjfU0w+Wbg+qy+kGMAoJ2D
abGDsKF5WwCWi/N3SjfKTLum
=J+M+
-----END PGP SIGNATURE-----
 
Thanks a lot for the tip. I'm surprised I didn't see that
in the HELP menue. It works great.

Ken

-----Original Message-----
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You can use the IIf() function in the SELECT clause. E.g.:

SELECT IIf([Basic Service Call]=True,a+b) As TrueSvcCall,
IIf([Basic Service Call]=False,a-b*c) As FalseSvcCall
FROM TableName
WHERE [Basic Service Call] Is Not Null

You could also put in a WHERE criteria that would ensure there are
values in the a, b & c columns (or whatever you are using to
calculate). Or you could use the Nz() function to prevent NULLs in
the calculations, which will return a NULL for the result.

Nz(a,0) + Nz(b,0)

HTH,

MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQBGISYechKqOuFEgEQKX3gCdErARv9zJedYjfU0w+Wbg+qy+kG MAoJ2D
abGDsKF5WwCWi/N3SjfKTLum
=J+M+
-----END PGP SIGNATURE-----

NOTE: I am writig this database in Access 97 (will later
use it on a computer with Offic XP version). Thanks

.
 
Back
Top