IIf statement with message box

shutzy

Registered User.
Local time
Today, 15:57
Joined
Sep 14, 2011
Messages
775
i am trying to put a message box in an if statement and im struggling.

iif([Voucher]>0 and [VoucherNumber]>0,=MsgBox("Please Bla Bla Bla",vbOK))

ive searched google and 'Tech On The Net' and i still cant figure out why it has an error

the error is Complie Error: Expected Expression

the part hightlighted is the = sign. i remove this and it then dosnt like part of the Message. i dont know what is happening.


any help?
 
Try something like this:

Code:
If [Voucher]>0 and [VoucherNumber]>0 then
     Msgbox "Your Message Here", vbOkOnly, "Message box title here"
end if
 
thanks mr. b. another question, how do i stop the vba going any further if true. with the macros i could just add stop macros underneath the statement.
 
If your code is in a sub you could use to immediately stop processing any more code:
Exit Sub

If your code is in a function, you could use to immediately stop processing any more code:
Exit Function



Code:
if ..... then
     'Message here
     
     Exit Sub  or Exit Function would go here
 
     'additional code here
 
endif
 

Users who are viewing this thread

Back
Top Bottom