Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if select?

Status
Not open for further replies.

SQLScholar

Programmer
Aug 21, 2002
2,127
GB
Hey all,

I have a program which is querying an access DB, using access SQL.

I have the query working nearly perfectly, apart from this problem.

If there is no data, it still produces the automated email. The reason for this, is that it puts in headers and stuff like this during the code.

So is there any way of saying

IF (select * from mytable='' then select * from mytable, else do the rest of the query)

So basically if the data in my table is empty then query just that (returns a blank, so no email) if its not then carry on.

Thanks all

Dan

----------------------------------------
There are 2 types of computer, the prototype and the obsolete!!
 
I have a program
You may first grab the return value of a SELECT Count(*) with the same FROM and WHERE clauses as the query.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
can i do the same testing against a slightly different query??

So would the code be

IIF(select count(*)from mytable1=0,'',SELECT..........)

----------------------------------------
There are 2 types of computer, the prototype and the obsolete!!
 
How your program is querying the database ?
With recordset ?
If your code is Access VBA you may consider the DCount function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Its a pre built program - querying via ODBC. Thats why i was hoping to do it in the SQL.

----------------------------------------
There are 2 types of computer, the prototype and the obsolete!!
 
If the code is below for the header - is there any way to make it say "only print this, if qrydan isnt blank"

Code:
select 'AF' as myprimaryorder,'','','','','','','DAYBOOK REPORT',first(QryDan.[Transaction Date]),'','','','','','','','
','NEW BUSINESS',''
From QryDan

Dan

----------------------------------------
There are 2 types of computer, the prototype and the obsolete!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top