If function

Chose.cz

Registered User.
Local time
Today, 06:24
Joined
Aug 8, 2006
Messages
12
Hello,

I've created the following code (not working)

testSQL= "SELECT Product FROM ...."
If IsNull(DoCmd.RunSQL(testSQL)) Then ...


When my SELECT statement returns no rows, I want my If code to be executed.
But the syntax above is incorrect. How do I fix it?

Thanks in advance
 
You should try using the dlookUp function to see if the product exists. Or to do it your way you need to open up a recordset and check for records.
 
dim rs as recordset
dim testsql as string

testsql = "SELECT Product FROM ...."
set rs = currentdb.openrecordset(testsql)

if rs.eof then
...
else
...
end if
 
FLM said:
dim rs as recordset
dim testsql as string

testsql = "SELECT Product FROM ...."
set rs = currentdb.openrecordset(testsql)

if rs.eof then
...
else
...
end if

Works, thanks again
 

Users who are viewing this thread

Back
Top Bottom