If/Then in SQL Embedded in VBA

Posted by Daniel on Stack Overflow See other posts from Stack Overflow or by Daniel
Published on 2010-06-15T20:21:14Z Indexed on 2010/06/15 20:22 UTC
Read the original article Hit count: 330

Filed under:
|
|
|
|

I've got a string like this in my Excel VBA:

strSQL = "SELECT * FROM Total WHERE (SimulationID = (" & TextBox1.Text & ") And Test1 = (" & Example & "))"

However, sometimes Test will be 'is null', which makes the query

And Example = is NULL

How can I change it to add an if/then statement or something to make it say

And Example is null

when Example has a value of "is null"?

© Stack Overflow or respective owner

Related posts about sql

Related posts about vba