MsgBox in SQL

E

Ernie

How can I implement the following so that a message box apperars if
ProjectClosed=-1

SELECT tblA.Project#, tblA.ProjectClosed
FROM tblA
IF tblA.ProjectClosed=-1
THEN MsgBox "This Project# has been closed", vbOKonly
ELSE
SELECT ...
FROM ...
WHERE ... ;

The last 3 commands work but I can't implement the IF ... THEN ... ELSE phrase
Regards,
Ernie
 
D

Duane Hookom

The select statement works on a set of records. You can't do what you want
using the method you want.

What are you attempting to do? You might need to create a recordset and loop
through it.
 
T

tkelley via AccessMonster.com

I'm having trouble understanding where your code is. Is this code that is in
VBA? Are you selecting into a recordset?
 
M

MGFoster

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

Access SQL doesn't allow IF...THEN statements in the SQL command. You
could just change the value of ProjectClosed from numbers to text like
this:

SELECT [Project#],
IIf(ProjectClosed=True,"Closed","Open") As ProjectStatus
FROM tblA
WHERE ....

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

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

iQA/AwUBSRC+Z4echKqOuFEgEQIyWwCgqNfg0Pt1QKPTbwunZExiXZrL1gwAoMeD
3Z8USoUDLqYIH+yH142z/qY6
=AQEo
-----END PGP SIGNATURE-----
 
Top