ISNULL statement in SQL to VBA string

W

wiebe21

Hello,

i'm trying to understand the functions of the ISNULL statement from
SQL to work in VBA but I can't seem to do it. The string i'm trying is
written below:

strngSQL = "SELECT g_prodvend.prodid, ISNULL(g_prodvend.salesprice,
1) / ISNULL(g_prodvend.costprice,1) FROM prodvend"

basicly what I like is to get the sales price factor out of my tables
does anyone see a error in either the ISNULL statement or something
thats wrong with dividing the two values.

Thx in advance

Wiebe
 
S

Stefan Hoffmann

hello Wiebe,

basicly what I like is to get the sales price factor out of my tables
does anyone see a error in either the ISNULL statement or something
thats wrong with dividing the two values.
Try

strngSQL = "SELECT g_prodvend.prodid, " & _
"Nz(g_prodvend.salesprice, 1) / " & _
"Nz(g_prodvend.costprice, 1) " & _
"FROM prodvend"

Btw, what happens when costprice is 0?


mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top