Compare SQL String

Edwik

Registered User.
Local time
Today, 15:26
Joined
Aug 19, 2005
Messages
40
Hi, all.

I have string: strSQL = SELECT SUM column FROM table

I need compare it with constant number, for Example:

If strSQL > 50000 Then ....

its not working, any Ideas?

Thank You in advance
 
Check out the DSum function in VBA help as this will do what you require.
 
Dsum its ok, bu I have more difficult situation (dont know is possibble to use Dsum Function?)

I Have 4 Tables:

TABLE1 with Columns (ID1, Col1)
TABLE2 with Columns (ID2, Col2A,col2B)
TABLE3 with Columns (ID3, Col3)
TABLE4 with Columns (ID4, Col4)


Col1 have relationship (one to many) with ID2
Col2A have relationship (one to many) with ID3
Col2B have relationship (one to one) with Col4


strSQL "SELECT SUM (Col1*Col4) FROM TABLE2 INNER JOIN TABLE3 ON TABLE2.Col2A = TABLE3.ID3 INNER JOIN TABLE4 ON TABLE2.Col2B = TABLE4.Col4 INNER JOIN TABLE1 ON TABLE2.ID2 = TABLE1.Col1 WHERE (ID3 = ' " & FORM.txtbox & " ')"

Is it possible convert it to Dsum?
 
It is easy if you know how...

In the code:

Dim rs as dao.recordset ' (may need to "reference" the microsoft DAO reference)
Set rs = currentdb.openrecordset("Select statement here")

But make sure to give your sum() an alias like Access does with Expr1

Then: If rs!Expr1 > 50000 then

make sure to close your recordset after using it:
rs.close ' close it
Set rs = nothing ' clean up totaly.
 

Users who are viewing this thread

Back
Top Bottom